Skip to content

Commit

Permalink
Use a static instance of hostname verifier in ClientCnx (apache#4415)
Browse files Browse the repository at this point in the history
  • Loading branch information
merlimat authored May 31, 2019
1 parent c756686 commit 38503b2
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ public class ClientCnx extends PulsarHandler {
// Remote hostName with which client is connected
protected String remoteHostName = null;
private boolean isTlsHostnameVerificationEnable;
private DefaultHostnameVerifier hostnameVerifier;

private static final DefaultHostnameVerifier HOSTNAME_VERIFIER = new DefaultHostnameVerifier();

private ScheduledFuture<?> timeoutTask;

Expand Down Expand Up @@ -170,7 +171,6 @@ public ClientCnx(ClientConfigurationData conf, EventLoopGroup eventLoopGroup, in
this.operationTimeoutMs = conf.getOperationTimeoutMs();
this.state = State.None;
this.isTlsHostnameVerificationEnable = conf.isTlsHostnameVerificationEnable();
this.hostnameVerifier = new DefaultHostnameVerifier();
this.protocolVersion = protocolVersion;
}

Expand Down Expand Up @@ -847,7 +847,7 @@ private boolean verifyTlsHostName(String hostname, ChannelHandlerContext ctx) {
log.debug("Verifying HostName for {}, Cipher {}, Protocols {}", hostname, sslSession.getCipherSuite(),
sslSession.getProtocol());
}
return hostnameVerifier.verify(hostname, sslSession);
return HOSTNAME_VERIFIER.verify(hostname, sslSession);
}
return false;
}
Expand Down

0 comments on commit 38503b2

Please sign in to comment.