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

Commit c628803

Browse files
author
Menon
committed
issue #580: support for configured TLS and cipherSuites
1 parent 0e1ba52 commit c628803

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/main/java/microsoft/exchange/webservices/data/core/EwsSSLProtocolSocketFactory.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525

2626
import org.apache.http.conn.ssl.DefaultHostnameVerifier;
2727
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
28+
import org.apache.http.impl.client.HttpClientBuilder;
2829
import org.apache.http.ssl.SSLContexts;
30+
import org.apache.http.util.TextUtils;
2931

3032
import javax.net.ssl.HostnameVerifier;
3133
import javax.net.ssl.SSLContext;
@@ -103,6 +105,19 @@ public EwsSSLProtocolSocketFactory(
103105
this.sslcontext = context;
104106
}
105107

108+
/**
109+
* Constructor for EasySSLProtocolSocketFactory.
110+
*
111+
* @param context SSL context
112+
* @param hostnameVerifier hostname verifier
113+
*/
114+
public EwsSSLProtocolSocketFactory(
115+
SSLContext context,String[] supportedProtocols, String[] supportedCipherSuites, HostnameVerifier hostnameVerifier
116+
) {
117+
super(context,supportedProtocols,supportedCipherSuites, hostnameVerifier);
118+
this.sslcontext = context;
119+
}
120+
106121

107122
/**
108123
* Create and configure SSL protocol socket factory using default hostname verifier.
@@ -129,7 +144,22 @@ public static EwsSSLProtocolSocketFactory build(
129144
TrustManager trustManager, HostnameVerifier hostnameVerifier
130145
) throws GeneralSecurityException {
131146
SSLContext sslContext = createSslContext(trustManager);
132-
return new EwsSSLProtocolSocketFactory(sslContext, hostnameVerifier);
147+
148+
//read system properties
149+
String[] keepAliveStrategyCopy = null;
150+
keepAliveStrategyCopy = split(System.getProperty("https.protocols"));
151+
String[] targetAuthStrategyCopy = null;
152+
targetAuthStrategyCopy = split(System.getProperty("https.cipherSuites"));
153+
154+
if(null != keepAliveStrategyCopy || null != targetAuthStrategyCopy) {
155+
return new EwsSSLProtocolSocketFactory(sslContext,keepAliveStrategyCopy,targetAuthStrategyCopy, hostnameVerifier);
156+
} else {
157+
return new EwsSSLProtocolSocketFactory(sslContext, hostnameVerifier);
158+
}
159+
160+
}
161+
private static String[] split(String s) {
162+
return TextUtils.isBlank(s)?null:s.split(" *, *");
133163
}
134164

135165
/**

0 commit comments

Comments
 (0)