Fix another bug in the proxy (#419)

The promise should be set outside the try block because if we want
warning only, we still want the promise to be set even if the
clientCertificate.checkValidity() throws an error.
This commit is contained in:
Lai Jiang 2019-12-18 16:24:23 -05:00 committed by GitHub
parent 625761c514
commit 751f5dfbe5

View file

@ -113,8 +113,6 @@ public class SslServerInitializer<C extends Channel> extends ChannelInitializer<
sslHandler.engine().getSession().getPeerCertificates()[0]; sslHandler.engine().getSession().getPeerCertificates()[0];
try { try {
clientCertificate.checkValidity(); clientCertificate.checkValidity();
Promise<X509Certificate> unusedPromise =
clientCertificatePromise.setSuccess(clientCertificate);
} catch (CertificateNotYetValidException | CertificateExpiredException e) { } catch (CertificateNotYetValidException | CertificateExpiredException e) {
logger.atWarning().withCause(e).log( logger.atWarning().withCause(e).log(
"Client certificate is not valid.\nHash: %s", "Client certificate is not valid.\nHash: %s",
@ -123,8 +121,11 @@ public class SslServerInitializer<C extends Channel> extends ChannelInitializer<
Promise<X509Certificate> unusedPromise = Promise<X509Certificate> unusedPromise =
clientCertificatePromise.setFailure(e); clientCertificatePromise.setFailure(e);
ChannelFuture unusedFuture2 = channel.close(); ChannelFuture unusedFuture2 = channel.close();
return;
} }
} }
Promise<X509Certificate> unusedPromise =
clientCertificatePromise.setSuccess(clientCertificate);
} else { } else {
Promise<X509Certificate> unusedPromise = Promise<X509Certificate> unusedPromise =
clientCertificatePromise.setFailure(future.cause()); clientCertificatePromise.setFailure(future.cause());