Skip to content

Commit 995479b

Browse files
committed
Updated ssl-2way to work with ml-gradle 4.x
The previous version used ml-gradle 3.x and Java Client 4. With ml-gradle 4.x using Java Client 5 and higher, an X509TrustManager must be explicitly provided (has to do with the Java Client changing from using Apache HTTP to OkHttp between major versions 4 and 5). Setting `restTrustManager` accomplishes that. Also had to bump up the SSL version to the standard TLSv1.2. This project will receive more updates soon so that it is easier to test with.
1 parent 4cec636 commit 995479b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

examples/ssl-2way-project/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
id "net.saliman.properties" version "1.5.1"
23
id "com.marklogic.ml-gradle" version "4.5.2"
34
}
45

@@ -77,10 +78,11 @@ if (project.hasProperty("mlKeystore")) {
7778
KeyManager[] key = keyManagerFactory.getKeyManagers()
7879

7980
// Initialize the SSL context with key and trust managers.
80-
SSLContext sslContext = SSLContext.getInstance("SSLv3")
81+
SSLContext sslContext = SSLContext.getInstance("TLSv1.2")
8182
sslContext.init(key, trust, null)
8283

8384
restSslContext = sslContext
85+
restTrustManager = trust[0]
8486

8587
// This turns off hostname verification unless mlVerifyServerHostname=true
8688
if (project.hasProperty("mlVerifyServerHostname") && mlVerifyServerHostname.toBoolean()) {

0 commit comments

Comments
 (0)