Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://WEBROOT.com:65300/code/service":HTTPS hostname wrong: should be <WEBROOT.com>; nested exception is java.io.IOException: HTTPS hostname wrong: should be <WEBROOT.com>
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:584)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:529)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:447)
at service.UploadRestClient.run(UploadRestClient.java:54)
at service.UploadDocument.main(UploadDocument.java:19)
Caused by: java.io.IOException: HTTPS hostname wrong: should be <WEBROOT.com>
at sun.net.www.protocol.https.HttpsClient.checkURLSpoofing(HttpsClient.java:612)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:537)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:81)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:568)
... 4 more
Add below code in your java file and run it .Replace
mytargethostname with your domain name which you are trying to access
static {
javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(
new javax.net.ssl.HostnameVerifier(){
public boolean verify(String |hostname|,
javax.net.ssl.SSLSession sslSession) {
if (hostname.equals("mytargethostname")) {
return true;
}
return false;
}
});
}
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:584)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:529)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:447)
at service.UploadRestClient.run(UploadRestClient.java:54)
at service.UploadDocument.main(UploadDocument.java:19)
Caused by: java.io.IOException: HTTPS hostname wrong: should be <WEBROOT.com>
at sun.net.www.protocol.https.HttpsClient.checkURLSpoofing(HttpsClient.java:612)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:537)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:81)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:568)
... 4 more
Add below code in your java file and run it .Replace
mytargethostname with your domain name which you are trying to access
static {
javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(
new javax.net.ssl.HostnameVerifier(){
public boolean verify(String |hostname|,
javax.net.ssl.SSLSession sslSession) {
if (hostname.equals("mytargethostname")) {
return true;
}
return false;
}
});
}
No comments:
Post a Comment