Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

The request failed.Host name does not match the certificate subject provided by the peer #351

Closed
kervin521 opened this issue Jun 16, 2015 · 4 comments
Labels

Comments

@kervin521
Copy link

String url = "https://192.168.0.168/EWS/Exchange.asmx";
String account = "*****@**.com";//
String password = "****";//
ExchangeCredentials credentials = new WebCredentials(account, password);
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.setCredentials(credentials);
service.setTraceEnabled(true);
service.setUrl(new URI(url));//
service.setPreAuthenticate(true);
service.setTimeout(10*60*1000);

the result:

com.wafersystems.exchange.core.exception.service.remote.ServiceRequestException: The request failed. The request failed. Host name '192.168.0.168' does not match the certificate subject provided by the peer (CN=exchange)
    at com.wafersystems.exchange.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:74)
    at com.wafersystems.exchange.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:158)
    at com.wafersystems.exchange.core.ExchangeService.findItems(ExchangeService.java:981)
    at com.wafersystems.exchange.core.ExchangeService.findItems(ExchangeService.java:1025)
    at com.wafersystems.exchange.core.ExchangeService.findItems(ExchangeService.java:1100)
    at com.wafersystems.ExchangeAPI.main(ExchangeAPI.java:53)
Caused by: com.wafersystems.exchange.core.exception.service.remote.ServiceRequestException: The request failed. Host name '192.168.0.168' does not match the certificate subject provided by the peer (CN=exchange)
    at com.wafersystems.exchange.core.request.ServiceRequestBase.getEwsHttpWebResponse(ServiceRequestBase.java:729)
    at com.wafersystems.exchange.core.request.ServiceRequestBase.validateAndEmitRequest(ServiceRequestBase.java:639)
    at com.wafersystems.exchange.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:62)
    ... 5 more
Caused by: javax.net.ssl.SSLPeerUnverifiedException: Host name '192.168.0.168' does not match the certificate subject provided by the peer (CN=exchange)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.verifyHostname(SSLConnectionSocketFactory.java:465)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:395)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
    at org.apache.http.impl.conn.BasicHttpClientConnectionManager.connect(BasicHttpClientConnectionManager.java:338)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    at com.wafersystems.exchange.core.request.HttpClientWebRequest.executeRequest(HttpClientWebRequest.java:292)
    at com.wafersystems.exchange.core.request.ServiceRequestBase.getEwsHttpWebResponse(ServiceRequestBase.java:720)
    ... 7 more
@kervin521 kervin521 changed the title The request failed.What can I do? The request failed.Host name does not match the certificate subject provided by the peer Jun 16, 2015
@serious6
Copy link
Member

some notes found on the net: stackoverflow

@serious6 serious6 added the bug label Jun 16, 2015
@kervin521
Copy link
Author

I have downloaded separately:

  • Apache Commons HttpClient 4.5 (httpclient-4.5.jar)
  • Apache Commons HttpCore 4.4.1 (httpcore-4.4.1.jar)
  • Apache Commons lang3 3.4 (commons-lang3-3.4.jar)
  • Apache Commons Codec 1.10 (commons-codec-1.10.jar)
  • Apache Commons Logging 1.2 (commons-logging-1.2.jar)
  • Joda Time 2.8(joda-time-2.8.jar)

but it found the same error , why?

@serious6
Copy link
Member

Maybe try using your own hostname verifier. Can be seen on the wiki

@serious6 serious6 added question and removed bug labels Jun 18, 2015
@BUxiaonan
Copy link

Is this problem solved?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants