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

Commit a5673fa

Browse files
committed
#119 SimpleX509TrustManager now defaults to TLSv1.2
And it accepts an argument for overriding that protocol
1 parent 5d50e01 commit a5673fa

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/main/java/com/marklogic/client/ext/modulesloader/ssl/SimpleX509TrustManager.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package com.marklogic.client.ext.modulesloader.ssl;
22

3-
import java.security.cert.CertificateException;
4-
import java.security.cert.X509Certificate;
5-
63
import javax.net.ssl.SSLContext;
74
import javax.net.ssl.TrustManager;
85
import javax.net.ssl.X509TrustManager;
6+
import java.security.cert.X509Certificate;
97

108
/**
119
* "Simple" in that it doesn't do anything. Useful for development, but you should consider something more robust for a
@@ -19,21 +17,25 @@ public class SimpleX509TrustManager implements X509TrustManager {
1917
* @return
2018
*/
2119
public static SSLContext newSSLContext() {
22-
try {
23-
SSLContext sslContext = SSLContext.getInstance("SSLv3");
24-
sslContext.init(null, new TrustManager[] { new SimpleX509TrustManager() }, null);
25-
return sslContext;
26-
} catch (Exception e) {
27-
throw new RuntimeException(e);
28-
}
20+
return newSSLContext("TLSv1.2");
2921
}
3022

23+
public static SSLContext newSSLContext(String protocol) {
24+
try {
25+
SSLContext sslContext = SSLContext.getInstance(protocol);
26+
sslContext.init(null, new TrustManager[] { new SimpleX509TrustManager() }, null);
27+
return sslContext;
28+
} catch (Exception e) {
29+
throw new RuntimeException(e);
30+
}
31+
}
32+
3133
@Override
32-
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
34+
public void checkClientTrusted(X509Certificate[] chain, String authType) {
3335
}
3436

3537
@Override
36-
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
38+
public void checkServerTrusted(X509Certificate[] chain, String authType) {
3739
}
3840

3941
@Override

0 commit comments

Comments
 (0)