Skip to content

Commit

Permalink
Address code review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta authored and ok2c committed Jan 14, 2025
1 parent 0ab5faf commit 6681eb7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,12 @@ public static SSLContext createServerSSLContext(final String protocol) {
final URL keyStoreURL = SSLTestContexts.class.getResource("/test.p12");
final String storePassword = "nopassword";
try {
SSLContextBuilder sslContextBuilder = SSLContextBuilder.create()
return SSLContextBuilder.create()
.setKeyStoreType("pkcs12")
.loadTrustMaterial(keyStoreURL, storePassword.toCharArray())
.loadKeyMaterial(keyStoreURL, storePassword.toCharArray(), storePassword.toCharArray());

if (protocol != null) {
sslContextBuilder = sslContextBuilder.setProtocol(protocol);
}

return sslContextBuilder.build();
.loadKeyMaterial(keyStoreURL, storePassword.toCharArray(), storePassword.toCharArray())
.setProtocol(protocol)
.build();
} catch (final NoSuchAlgorithmException | KeyManagementException | KeyStoreException | CertificateException |
UnrecoverableKeyException | IOException ex) {
throw new IllegalStateException(ex);
Expand All @@ -72,15 +68,11 @@ public static SSLContext createClientSSLContext(final String protocol) {
final URL keyStoreURL = SSLTestContexts.class.getResource("/test.p12");
final String storePassword = "nopassword";
try {
SSLContextBuilder sslContextBuilder = SSLContextBuilder.create()
return SSLContextBuilder.create()
.setKeyStoreType("pkcs12")
.loadTrustMaterial(keyStoreURL, storePassword.toCharArray());

if (protocol != null) {
sslContextBuilder = sslContextBuilder.setProtocol(protocol);
}

return sslContextBuilder.build();
.loadTrustMaterial(keyStoreURL, storePassword.toCharArray())
.setProtocol(protocol)
.build();
} catch (final NoSuchAlgorithmException | KeyManagementException | KeyStoreException | CertificateException |
IOException ex) {
throw new IllegalStateException(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ public H2CoreTransportTest(final URIScheme scheme) {
this(scheme, null);
}

public H2CoreTransportTest(final URIScheme scheme, final String protocol) {
public H2CoreTransportTest(final URIScheme scheme, final String tlsProtocol) {
super(scheme);
this.serverResource = new H2AsyncServerResource();
this.serverResource.configure(bootstrap -> bootstrap
.setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
.setTlsStrategy(new H2ServerTlsStrategy(SSLTestContexts.createServerSSLContext(protocol)))
.setTlsStrategy(new H2ServerTlsStrategy(SSLTestContexts.createServerSSLContext(tlsProtocol)))
.setIOReactorConfig(
IOReactorConfig.custom()
.setSoTimeout(TIMEOUT)
Expand All @@ -76,7 +76,7 @@ public H2CoreTransportTest(final URIScheme scheme, final String protocol) {
this.clientResource = new H2AsyncRequesterResource();
this.clientResource.configure(bootstrap -> bootstrap
.setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
.setTlsStrategy(new H2ClientTlsStrategy(SSLTestContexts.createClientSSLContext(protocol)))
.setTlsStrategy(new H2ClientTlsStrategy(SSLTestContexts.createClientSSLContext(tlsProtocol)))
.setIOReactorConfig(IOReactorConfig.custom()
.setSoTimeout(TIMEOUT)
.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ public Http1CoreTransportTest(final URIScheme scheme) {
this(scheme, null);
}

public Http1CoreTransportTest(final URIScheme scheme, final String protocol) {
public Http1CoreTransportTest(final URIScheme scheme, final String tlsProtocol) {
super(scheme);
this.serverResource = new HttpAsyncServerResource();
this.serverResource.configure(bootstrap -> bootstrap
.setTlsStrategy(new H2ServerTlsStrategy(SSLTestContexts.createServerSSLContext(protocol)))
.setTlsStrategy(new H2ServerTlsStrategy(SSLTestContexts.createServerSSLContext(tlsProtocol)))
.setIOReactorConfig(
IOReactorConfig.custom()
.setSoTimeout(TIMEOUT)
Expand Down Expand Up @@ -125,7 +125,7 @@ public void pushPromise(
);
this.clientResource = new HttpAsyncRequesterResource();
this.clientResource.configure(bootstrap -> bootstrap
.setTlsStrategy(new H2ClientTlsStrategy(SSLTestContexts.createClientSSLContext(protocol)))
.setTlsStrategy(new H2ClientTlsStrategy(SSLTestContexts.createClientSSLContext(tlsProtocol)))
.setIOReactorConfig(IOReactorConfig.custom()
.setSoTimeout(TIMEOUT)
.build())
Expand Down

0 comments on commit 6681eb7

Please sign in to comment.