Skip to content

Instantly share code, notes, and snippets.

@krnbr
Last active July 19, 2020 11:04
Show Gist options
  • Save krnbr/51e613477b447274a0c9db4f971b6999 to your computer and use it in GitHub Desktop.
Save krnbr/51e613477b447274a0c9db4f971b6999 to your computer and use it in GitHub Desktop.
// pass the base 64 encoded String of the Keystore and keystore password
KeyManagerFactory keyManagerFactory = SSLContextHelper.getKeyStore(encodedKeystoreString, keystorePassword);
// pass the base 64 encoded String of the Truststore and truststore password
TrustManagerFactory trustManagerFactory = SSLContextHelper.getTrustStore(encodedTruststoreString, truststorePassword);
// Construct the SslContext using keyManagerFactory & trustManagerFactory
SslContext sslContext = SSLContextHelper.sslContext(keyManagerFactory, trustManagerFactory);
HttpClient resourceServerHttpClient = HttpClient.create()
.tcpConfiguration(client -> client.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000))
.secure(sslContextSpec -> {
sslContextSpec.sslContext(sslContext);
});
ClientHttpConnector customHttpConnector = new ReactorClientHttpConnector(resourceServerHttpClient);
return WebClient.builder()
// base path of the client, this way we need to set the complete url again
.baseUrl(testClientBaseUrl)
.clientConnector(customHttpConnector)
.filter(oauth)
.filter(logRequest())
.filter(logResponse())
.build();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment