Skip to content

Commit

Permalink
UNDERTOW-1493: Allow specific protocol for client SSL context.
Browse files Browse the repository at this point in the history
Trying to test issues specific to some protocol without being in control
of the protocol used can lead to false negatives.
  • Loading branch information
lonemeow committed Feb 20, 2019
1 parent cbcdcf8 commit d47a344
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/src/test/java/io/undertow/testutils/DefaultServer.java
Expand Up @@ -177,6 +177,10 @@ private static KeyStore loadKeyStore(final String name) throws IOException {
}

private static SSLContext createSSLContext(final KeyStore keyStore, final KeyStore trustStore, boolean client) throws IOException {
return createSSLContext(keyStore, trustStore, "TLSv1.2", client);
}

private static SSLContext createSSLContext(final KeyStore keyStore, final KeyStore trustStore, String protocol, boolean client) throws IOException {
KeyManager[] keyManagers;
try {
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
Expand All @@ -200,7 +204,7 @@ private static SSLContext createSSLContext(final KeyStore keyStore, final KeySto
if (openssl && !client) {
sslContext = SSLContext.getInstance("openssl.TLS");
} else {
sslContext = SSLContext.getInstance("TLSv1.2");
sslContext = SSLContext.getInstance(protocol);
}
sslContext.init(keyManagers, trustManagers, null);
} catch (NoSuchAlgorithmException | KeyManagementException e) {
Expand Down Expand Up @@ -605,8 +609,12 @@ public static void startSSLServer() throws IOException {
}

public static SSLContext createClientSslContext() {
return createClientSslContext("TLSv1.2");
}

public static SSLContext createClientSslContext(String protocol) {
try {
return createSSLContext(loadKeyStore(CLIENT_KEY_STORE), loadKeyStore(CLIENT_TRUST_STORE), true);
return createSSLContext(loadKeyStore(CLIENT_KEY_STORE), loadKeyStore(CLIENT_TRUST_STORE), protocol, true);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit d47a344

Please sign in to comment.