+ Start a Discussion
Gino BassoGino Basso 

System.CalloutException: IO Exception: HTTPS hostname wrong: should be ...

We have Apex code that connects with a 3rd-party web service using 2-way SSL. As such, we're specifing values for clientCert_x and clientCertPasswd_x.
 
We're getting the exception specified in the subject line. My understanding is that the Salesforce servers are rejecting the SSL connection (or communication) because the hostname in the certiificate returned by the 3rd-party server does not match the hostname in the endpoint URL.
 
There are numerous posts on the web about how to overcome this in Java (i.e. server-side), such as replacing the default hostname verifier on the connection object, though obviously such a solution is not available in this particular case.
 
Is there anything that can be done on the Salesforce side to overcome this problem? For example, can additional hostname values be specified that will be allowed in addition to the one in the endpoint?
 
SuperfellSuperfell
No, you can't override this, the host in the URL and the certificate need to match.