Skip to content

Added sslcontext to SSE #576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<parent>
<groupId>io.split.client</groupId>
<artifactId>java-client-parent</artifactId>
<version>4.16.0</version>
<version>4.17.0-rc1</version>
</parent>
<version>4.16.0</version>
<version>4.17.0-rc1</version>
<artifactId>java-client</artifactId>
<packaging>jar</packaging>
<name>Java Client</name>
Expand Down
45 changes: 26 additions & 19 deletions client/src/main/java/io/split/client/SplitFactoryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -523,24 +523,7 @@ protected static SplitHttpClient buildSplitHttpClient(String apiToken, SplitClie
SDKMetadata sdkMetadata, RequestDecorator requestDecorator)
throws URISyntaxException {

SSLContext sslContext;
if (config.proxyMTLSAuth() != null) {
_log.debug("Proxy setup using mTLS");
try {
KeyStore keyStore = KeyStore.getInstance("PKCS12");
InputStream keystoreStream = java.nio.file.Files.newInputStream(Paths.get(config.proxyMTLSAuth().getP12File()));
keyStore.load(keystoreStream, config.proxyMTLSAuth().getP12FilePassKey().toCharArray());
sslContext = SSLContexts.custom()
.loadKeyMaterial(keyStore, config.proxyMTLSAuth().getP12FilePassKey().toCharArray())
.build();
} catch (Exception e) {
_log.error("Exception caught while processing p12 file for Proxy mTLS auth: ", e);
_log.warn("Ignoring p12 mTLS config and switching to default context");
sslContext = SSLContexts.createSystemDefault();
}
} else {
sslContext = SSLContexts.createSystemDefault();
}
SSLContext sslContext = buildSSLContext(config);

SSLConnectionSocketFactory sslSocketFactory = SSLConnectionSocketFactoryBuilder.create()
.setSslContext(sslContext)
Expand Down Expand Up @@ -585,8 +568,10 @@ private static CloseableHttpClient buildSSEdHttpClient(String apiToken, SplitCli
.setConnectTimeout(Timeout.ofMilliseconds(SSE_CONNECT_TIMEOUT))
.build();

SSLContext sslContext = buildSSLContext(config);

SSLConnectionSocketFactory sslSocketFactory = SSLConnectionSocketFactoryBuilder.create()
.setSslContext(SSLContexts.createSystemDefault())
.setSslContext(sslContext)
.setTlsVersions(TLS.V_1_1, TLS.V_1_2)
.build();

Expand All @@ -613,6 +598,28 @@ private static CloseableHttpClient buildSSEdHttpClient(String apiToken, SplitCli
return httpClientbuilder.build();
}

private static SSLContext buildSSLContext(SplitClientConfig config) {
SSLContext sslContext;
if (config.proxyMTLSAuth() != null) {
_log.debug("Proxy setup using mTLS");
try {
KeyStore keyStore = KeyStore.getInstance("PKCS12");
InputStream keystoreStream = java.nio.file.Files.newInputStream(Paths.get(config.proxyMTLSAuth().getP12File()));
keyStore.load(keystoreStream, config.proxyMTLSAuth().getP12FilePassKey().toCharArray());
sslContext = SSLContexts.custom()
.loadKeyMaterial(keyStore, config.proxyMTLSAuth().getP12FilePassKey().toCharArray())
.build();
} catch (Exception e) {
_log.error("Exception caught while processing p12 file for Proxy mTLS auth: ", e);
_log.warn("Ignoring p12 mTLS config and switching to default context");
sslContext = SSLContexts.createSystemDefault();
}
} else {
sslContext = SSLContexts.createSystemDefault();
}
return sslContext;
}

private static HttpClientBuilder setupProxy(HttpClientBuilder httpClientbuilder, SplitClientConfig config) {
_log.info("Initializing Split SDK with proxy settings");
DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(config.proxy());
Expand Down
4 changes: 2 additions & 2 deletions okhttp-modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<parent>
<artifactId>java-client-parent</artifactId>
<groupId>io.split.client</groupId>
<version>4.16.0</version>
<version>4.17.0-rc1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>4.16.0</version>
<version>4.17.0-rc1</version>
<artifactId>okhttp-modules</artifactId>
<packaging>jar</packaging>
<name>http-modules</name>
Expand Down
2 changes: 1 addition & 1 deletion pluggable-storage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>java-client-parent</artifactId>
<groupId>io.split.client</groupId>
<version>4.16.0</version>
<version>4.17.0-rc1</version>
</parent>

<version>2.1.0</version>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.split.client</groupId>
<artifactId>java-client-parent</artifactId>
<version>4.16.0</version>
<version>4.17.0-rc1</version>
<dependencyManagement>
<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion redis-wrapper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>java-client-parent</artifactId>
<groupId>io.split.client</groupId>
<version>4.16.0</version>
<version>4.17.0-rc1</version>
</parent>
<artifactId>redis-wrapper</artifactId>
<version>3.1.1</version>
Expand Down
2 changes: 1 addition & 1 deletion testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>
<artifactId>java-client-testing</artifactId>
<packaging>jar</packaging>
<version>4.16.0</version>
<version>4.17.0-rc1</version>
<name>Java Client For Testing</name>
<description>Testing suite for Java SDK for Split</description>
<dependencies>
Expand Down
Loading