Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

issue #580 : support for configured TLS and cipherSuites #628

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.http.conn.ssl.DefaultHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.TextUtils;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
Expand Down Expand Up @@ -103,6 +104,22 @@ public EwsSSLProtocolSocketFactory(
this.sslcontext = context;
}

/**
* Constructor for EasySSLProtocolSocketFactory.
*
* @param context SSL context
* @param supportedProtocols protocol from sys prop
* @param supportedCipherSuites cipherSuites from sys prop
* @param hostnameVerifier hostname verifier
*/
public EwsSSLProtocolSocketFactory(
SSLContext context,String[] supportedProtocols, String[] supportedCipherSuites,
HostnameVerifier hostnameVerifier
) {
super(context,supportedProtocols,supportedCipherSuites, hostnameVerifier);
this.sslcontext = context;
}


/**
* Create and configure SSL protocol socket factory using default hostname verifier.
Expand All @@ -129,7 +146,22 @@ public static EwsSSLProtocolSocketFactory build(
TrustManager trustManager, HostnameVerifier hostnameVerifier
) throws GeneralSecurityException {
SSLContext sslContext = createSslContext(trustManager);
return new EwsSSLProtocolSocketFactory(sslContext, hostnameVerifier);

//read system properties
String[] keepAliveStrategyCopy;
keepAliveStrategyCopy = split(System.getProperty("https.protocols"));
String[] targetAuthStrategyCopy;
targetAuthStrategyCopy = split(System.getProperty("https.cipherSuites"));

if (null != keepAliveStrategyCopy || null != targetAuthStrategyCopy) {
return new EwsSSLProtocolSocketFactory(sslContext,keepAliveStrategyCopy,targetAuthStrategyCopy, hostnameVerifier);
} else {
return new EwsSSLProtocolSocketFactory(sslContext, hostnameVerifier);
}
}

private static String[] split(String s) {
return TextUtils.isBlank(s)?null:s.split(" *, *");
}

/**
Expand Down