Throw exception if KeyManagerFactory is used with OpenSslServerContext

Motivation:

We currently not supported using KeyManagerFactory with OpenSslServerContext and so should throw an exception if the user tries to do so. This will at least not give suprising and hard to debug problems later.

Modifications:

Throw exception if a user tries to construct a OpenSslServerContext with a KeyManagerFactory

Result:

Fail fast if the user tries to use something that is not supported.
This commit is contained in:
Norman Maurer 2015-12-15 15:06:54 +01:00
parent 2202e8f967
commit dd9fc289fd

View File

@ -321,6 +321,7 @@ public final class OpenSslServerContext extends OpenSslContext {
ClientAuth.NONE);
OpenSsl.ensureAvailability();
checkKeyManagerFactory(keyManagerFactory);
checkNotNull(keyCertChainFile, "keyCertChainFile");
if (!keyCertChainFile.isFile()) {
throw new IllegalArgumentException("keyCertChainFile is not a file: " + keyCertChainFile);
@ -420,6 +421,7 @@ public final class OpenSslServerContext extends OpenSslContext {
clientAuth);
OpenSsl.ensureAvailability();
checkKeyManagerFactory(keyManagerFactory);
checkNotNull(keyCertChain, "keyCertChainFile");
checkNotNull(key, "keyFile");
@ -528,4 +530,11 @@ public final class OpenSslServerContext extends OpenSslContext {
public OpenSslServerSessionContext sessionContext() {
return sessionContext;
}
private static void checkKeyManagerFactory(KeyManagerFactory keyManagerFactory) {
if (keyManagerFactory != null) {
throw new IllegalArgumentException(
"KeyManagerFactory is currently not supported with OpenSslServerContext");
}
}
}