Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLParameters;

public class JsseSslEngineFactory extends SslEngineFactoryBase {

Expand All @@ -31,6 +32,14 @@ public JsseSslEngineFactory(SSLContext sslContext) {
@Override
public SSLEngine newSslEngine(AsyncHttpClientConfig config, String peerHost, int peerPort) {
SSLEngine sslEngine = sslContext.createSSLEngine(domain(peerHost), peerPort);
// A JDK SSLEngine does not verify the peer hostname unless the endpoint identification algorithm
// is set, so without this a certificate valid for any host would be accepted. Enable it to match
// DefaultSslEngineFactory, honoring disableHttpsEndpointIdentificationAlgorithm.
if (!config.isDisableHttpsEndpointIdentificationAlgorithm()) {
SSLParameters params = sslEngine.getSSLParameters();
params.setEndpointIdentificationAlgorithm("HTTPS");
sslEngine.setSSLParameters(params);
}
configureSslEngine(sslEngine, config);
return sslEngine;
}
Expand Down
Loading