dimanche 1 mars 2015

How to use hostname verification with Jersey 1.17 and apache connector



Currently I'm able to connect successfully over https with Jersey using the apache connector, but the hostname verification I've set does not appear to be used.



HostnameVerifier hostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(final String hostname, final SSLSession session) {
return false;
}
};
HTTPSProperties httpsProperties = new HTTPSProperties(hostnameVerifier, sslContext);
final ApacheHttpClientConfig clientConfig = new DefaultApacheHttpClientConfig();
clientConfig.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, httpsProperties);
final Client client = this.clientFactory.getClient(clientConfig);


The HTTPS settings work fine, except the hostname verification. No logging output, and breakpoints are not hit within the verify method. Wondering if I'm setting the hostname verifier incorrectly?


(side note - I realise 1.17 isn't the latest version of jersey, but at the moment updating isn't a good option for me).




Aucun commentaire:

Enregistrer un commentaire