Skip to content

Commit 8c54468

Browse files
authored
Turn off hostname verification for trustAllCertificates TrustStrategy (#1301)
`Config.TrustStrategy.trustAllCertificates()` should return `TrustStrategy` with hostname verification turned off by default. This update is part of behaviour unification among the official drivers.
1 parent 9448c90 commit 8c54468

File tree

2 files changed

+4
-8
lines changed
  • driver/src/main/java/org/neo4j/driver
  • testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests

2 files changed

+4
-8
lines changed

driver/src/main/java/org/neo4j/driver/Config.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,12 +790,14 @@ public static TrustStrategy trustSystemCertificates() {
790790

791791
/**
792792
* Trust strategy for certificates that trust all certificates blindly. Suggested to only use this in tests.
793+
* <p>
794+
* This trust strategy comes with hostname verification turned off by default since driver version 5.0.
793795
*
794796
* @return an authentication config
795797
* @since 1.1
796798
*/
797799
public static TrustStrategy trustAllCertificates() {
798-
return new TrustStrategy(Strategy.TRUST_ALL_CERTIFICATES);
800+
return new TrustStrategy(Strategy.TRUST_ALL_CERTIFICATES).withoutHostnameVerification();
799801
}
800802

801803
/**

testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests/StartTest.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,7 @@ public class StartTest implements TestkitRequest {
6262
COMMON_SKIP_PATTERN_TO_REASON.put(
6363
"^.*\\.test_partial_summary_contains_updates$", "Does not contain updates because value is zero");
6464
COMMON_SKIP_PATTERN_TO_REASON.put("^.*\\.test_supports_multi_db$", "Database is None");
65-
String skipMessage =
66-
"This test expects hostname verification to be turned off when all certificates are trusted";
67-
COMMON_SKIP_PATTERN_TO_REASON.put(
68-
"^.*\\.TestTrustAllCertsConfig\\.test_trusted_ca_wrong_hostname$", skipMessage);
69-
COMMON_SKIP_PATTERN_TO_REASON.put(
70-
"^.*\\.TestTrustAllCertsConfig\\.test_untrusted_ca_wrong_hostname$", skipMessage);
71-
skipMessage = "Driver handles connection acquisition timeout differently";
65+
var skipMessage = "Driver handles connection acquisition timeout differently";
7266
COMMON_SKIP_PATTERN_TO_REASON.put(
7367
"^.*\\.TestConnectionAcquisitionTimeoutMs\\.test_should_encompass_the_handshake_time.*$", skipMessage);
7468
COMMON_SKIP_PATTERN_TO_REASON.put(

0 commit comments

Comments
 (0)