Skip to content

Commit ac6e6c6

Browse files
authored
Correct behaviour for +s and +ssc. +s enable hostname verfication whereas +ssc disables it. (#720)
1 parent 239d9de commit ac6e6c6

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

driver/src/main/java/org/neo4j/driver/internal/SecuritySettings.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ private SecurityPlan createSecurityPlanFromScheme( String scheme ) throws Genera
9292
{
9393
if ( isHighTrustScheme(scheme) )
9494
{
95-
return SecurityPlanImpl.forSystemCASignedCertificates( trustStrategy.isHostnameVerificationEnabled() );
95+
return SecurityPlanImpl.forSystemCASignedCertificates( true );
9696
}
9797
else
9898
{
99-
return SecurityPlanImpl.forAllCertificates( trustStrategy.isHostnameVerificationEnabled() );
99+
return SecurityPlanImpl.forAllCertificates( false );
100100
}
101101
}
102102

driver/src/test/java/org/neo4j/driver/internal/SecuritySettingsTest.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,22 @@ void testSystemCertCompatibleConfiguration( String scheme ) throws Exception
7575
SSLContext defaultContext = SSLContext.getDefault();
7676

7777
assertTrue( securityPlan.requiresEncryption() );
78+
assertTrue( securityPlan.requiresHostnameVerification() );
7879
assertEquals( defaultContext, securityPlan.sslContext() );
7980
}
8081

82+
@ParameterizedTest
83+
@MethodSource( "selfSignedSchemes" )
84+
void testSelfSignedCertConfigDisablesHostnameVerification( String scheme ) throws Exception
85+
{
86+
SecuritySettings securitySettings = new SecuritySettings.SecuritySettingsBuilder().build();
87+
88+
SecurityPlan securityPlan = securitySettings.createSecurityPlan( scheme );
89+
90+
assertTrue( securityPlan.requiresEncryption() );
91+
assertFalse( securityPlan.requiresHostnameVerification() );
92+
}
93+
8194
@ParameterizedTest
8295
@MethodSource( "allSchemes" )
8396
void testThrowsOnUserCustomizedEncryption( String scheme )
@@ -156,7 +169,7 @@ void testConfiguredEncryption()
156169
}
157170

158171
@Test
159-
void testConfiguredAllCertificates() throws NoSuchAlgorithmException
172+
void testConfiguredAllCertificates()
160173
{
161174
SecuritySettings securitySettings = new SecuritySettings.SecuritySettingsBuilder()
162175
.withEncryption()

0 commit comments

Comments
 (0)