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 5949aebe82
commit 2336de5a9f
1 changed files with 9 additions and 0 deletions

View File

@ -295,6 +295,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);
@ -394,6 +395,7 @@ public final class OpenSslServerContext extends OpenSslContext {
clientAuth);
OpenSsl.ensureAvailability();
checkKeyManagerFactory(keyManagerFactory);
checkNotNull(keyCertChain, "keyCertChainFile");
checkNotNull(key, "keyFile");
@ -502,4 +504,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");
}
}
}