Ensure native memory is released when OpenSslServercontext constructor throws exception
Motivation: We need to ensure we do all checks inside of the try / catch block so we free native memory that was allocated in the constructor of the super class in a timely manner. Modifications: Move all checks inside of the try block. Result: Correctly release native memory (and not depend on the finalizer) when a check in the constructors fails
This commit is contained in:
parent
0310d79edf
commit
77f57a1434
@ -340,8 +340,9 @@ public final class OpenSslServerContext extends OpenSslContext {
|
|||||||
long sessionCacheSize, long sessionTimeout, ClientAuth clientAuth) throws SSLException {
|
long sessionCacheSize, long sessionTimeout, ClientAuth clientAuth) throws SSLException {
|
||||||
super(ciphers, cipherFilter, apn, sessionCacheSize, sessionTimeout, SSL.SSL_MODE_SERVER, keyCertChain,
|
super(ciphers, cipherFilter, apn, sessionCacheSize, sessionTimeout, SSL.SSL_MODE_SERVER, keyCertChain,
|
||||||
clientAuth);
|
clientAuth);
|
||||||
OpenSsl.ensureAvailability();
|
// Create a new SSL_CTX and configure it.
|
||||||
|
boolean success = false;
|
||||||
|
try {
|
||||||
checkKeyManagerFactory(keyManagerFactory);
|
checkKeyManagerFactory(keyManagerFactory);
|
||||||
checkNotNull(keyCertChain, "keyCertChainFile");
|
checkNotNull(keyCertChain, "keyCertChainFile");
|
||||||
checkNotNull(key, "keyFile");
|
checkNotNull(key, "keyFile");
|
||||||
@ -350,9 +351,6 @@ public final class OpenSslServerContext extends OpenSslContext {
|
|||||||
keyPassword = "";
|
keyPassword = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new SSL_CTX and configure it.
|
|
||||||
boolean success = false;
|
|
||||||
try {
|
|
||||||
synchronized (OpenSslContext.class) {
|
synchronized (OpenSslContext.class) {
|
||||||
/* Set certificate verification policy. */
|
/* Set certificate verification policy. */
|
||||||
SSLContext.setVerify(ctx, SSL.SSL_CVERIFY_NONE, VERIFY_DEPTH);
|
SSLContext.setVerify(ctx, SSL.SSL_CVERIFY_NONE, VERIFY_DEPTH);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user