Skip to content

Commit

Permalink
Correctly delete SelfSignedCertificate once done with it.
Browse files Browse the repository at this point in the history
Motivation:

In OpenSsl init code we create a SelfSignedCertificate which we not explicitly delete. This can lead to have the deletion delayed.

Modifications:

Delete the SelfSignedCertificate once done with it.

Result:

Fixes [netty#6716]
  • Loading branch information
normanmaurer committed May 9, 2017
1 parent 63f5cdb commit ec935c5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion handler/src/main/java/io/netty/handler/ssl/OpenSsl.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public final class OpenSsl {
final long sslCtx = SSLContext.make(SSL.SSL_PROTOCOL_ALL, SSL.SSL_MODE_SERVER);
long privateKeyBio = 0;
long certBio = 0;
SelfSignedCertificate cert = null;
try {
SSLContext.setCipherSuite(sslCtx, "ALL");
final long ssl = SSL.newSSL(sslCtx, true);
Expand All @@ -140,7 +141,7 @@ public final class OpenSsl {
logger.debug("Hostname Verification not supported.");
}
try {
SelfSignedCertificate cert = new SelfSignedCertificate();
cert = new SelfSignedCertificate();
certBio = ReferenceCountedOpenSslContext.toBIO(cert.cert());
SSL.setCertificateChainBio(ssl, certBio, false);
supportsKeyManagerFactory = true;
Expand All @@ -166,6 +167,9 @@ public Boolean run() {
if (certBio != 0) {
SSL.freeBIO(certBio);
}
if (cert != null) {
cert.delete();
}
}
} finally {
SSLContext.free(sslCtx);
Expand Down

0 comments on commit ec935c5

Please sign in to comment.