From 8727aae5c16e4e2e6a597969a1c7f5250bc3096b Mon Sep 17 00:00:00 2001 From: Dmitriy Tverdiakov Date: Wed, 17 Mar 2021 16:50:33 +0000 Subject: [PATCH] Fixed SSL handling This update fixes a number of SSL-related tests in testkit and CausalClusteringIT.shouldDropBrokenOldConnections test. The connection pooling strategy has been updated to use the same connection pool when the connection host is unambiguous. Removed hardcoded domain name resolution from the BoltServerAddress and moved the logic to ChannelConnectorImpl that uses the DomainNameResolver. --- .../driver/internal/BoltServerAddress.java | 58 ++++----- .../internal/ResolvedBoltServerAddress.java | 115 ++++++++++++++++++ .../connection/ChannelConnectorImpl.java | 17 ++- .../internal/cluster/RediscoveryImpl.java | 23 ++-- .../cluster/RoutingTableHandlerImpl.java | 14 +-- .../cluster/ClusterCompositionTest.java | 24 ++-- .../internal/cluster/RediscoveryTest.java | 2 +- .../internal/net/BoltServerAddressTest.java | 13 -- .../org/neo4j/driver/util/Neo4jRunner.java | 4 +- .../backend/messages/requests/NewDriver.java | 10 +- 10 files changed, 197 insertions(+), 83 deletions(-) create mode 100644 driver/src/main/java/org/neo4j/driver/internal/ResolvedBoltServerAddress.java diff --git a/driver/src/main/java/org/neo4j/driver/internal/BoltServerAddress.java b/driver/src/main/java/org/neo4j/driver/internal/BoltServerAddress.java index 8d8b4b23af..eacd6b2a39 100644 --- a/driver/src/main/java/org/neo4j/driver/internal/BoltServerAddress.java +++ b/driver/src/main/java/org/neo4j/driver/internal/BoltServerAddress.java @@ -18,14 +18,9 @@ */ package org.neo4j.driver.internal; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.SocketAddress; import java.net.URI; -import java.util.Collections; -import java.util.LinkedHashSet; import java.util.Objects; -import java.util.Set; +import java.util.stream.Stream; import org.neo4j.driver.net.ServerAddress; @@ -39,11 +34,10 @@ public class BoltServerAddress implements ServerAddress public static final int DEFAULT_PORT = 7687; public static final BoltServerAddress LOCAL_DEFAULT = new BoltServerAddress( "localhost", DEFAULT_PORT ); - private final String host; // This could either be the same as originalHost or it is an IP address resolved from the original host. - private final int port; + protected final String host; // Host or IP address. + private final String connectionHost; // Either is equal to the host or is explicitly provided on creation and is expected to be a resolved IP address. + protected final int port; private final String stringValue; - - private final Set resolved; public BoltServerAddress( String address ) { @@ -57,15 +51,17 @@ public BoltServerAddress( URI uri ) public BoltServerAddress( String host, int port ) { - this( host, port, Collections.emptySet() ); + this( host, host, port ); } - public BoltServerAddress( String host, int port, Set resolved ) + public BoltServerAddress( String host, String connectionHost, int port ) { this.host = requireNonNull( host, "host" ); + this.connectionHost = requireNonNull( connectionHost, "connectionHost" ); this.port = requireValidPort( port ); - this.stringValue = String.format( "%s:%d", host, port ); - this.resolved = Collections.unmodifiableSet( new LinkedHashSet<>( resolved ) ); + this.stringValue = host.equals( connectionHost ) + ? String.format( "%s:%d", host, port ) + : String.format( "%s(%s):%d", host, connectionHost, port ); } public static BoltServerAddress from( ServerAddress address ) @@ -86,14 +82,14 @@ public boolean equals( Object o ) { return false; } - BoltServerAddress that = (BoltServerAddress) o; - return port == that.port && host.equals( that.host ); + BoltServerAddress address = (BoltServerAddress) o; + return port == address.port && host.equals( address.host ) && connectionHost.equals( address.connectionHost ); } @Override public int hashCode() { - return Objects.hash( host, port ); + return Objects.hash( host, connectionHost, port ); } @Override @@ -102,18 +98,6 @@ public String toString() return stringValue; } - /** - * Create a {@link SocketAddress} from this bolt address. This method always attempts to resolve the hostname into - * an {@link InetAddress}. - * - * @return new socket address. - * @see InetSocketAddress - */ - public SocketAddress toSocketAddress() - { - return new InetSocketAddress( host, port ); - } - @Override public String host() { @@ -126,9 +110,21 @@ public int port() return port; } - public Set resolved() + public String connectionHost() + { + return connectionHost; + } + + /** + * Create a stream of unicast addresses. + *

+ * While this implementation just returns a stream of itself, the subclasses may provide multiple addresses. + * + * @return stream of unicast addresses. + */ + public Stream unicastStream() { - return this.resolved; + return Stream.of( this ); } private static String hostFrom( URI uri ) diff --git a/driver/src/main/java/org/neo4j/driver/internal/ResolvedBoltServerAddress.java b/driver/src/main/java/org/neo4j/driver/internal/ResolvedBoltServerAddress.java new file mode 100644 index 0000000000..6fa357f987 --- /dev/null +++ b/driver/src/main/java/org/neo4j/driver/internal/ResolvedBoltServerAddress.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) "Neo4j" + * Neo4j Sweden AB [http://neo4j.com] + * + * This file is part of Neo4j. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.neo4j.driver.internal; + +import java.net.InetAddress; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Stream; + +import static java.util.Objects.requireNonNull; +import static java.util.stream.Collectors.joining; + +/** + * An explicitly resolved version of {@link BoltServerAddress} that always contains one or more resolved IP addresses. + */ +public class ResolvedBoltServerAddress extends BoltServerAddress +{ + private static final String HOST_ADDRESSES_FORMAT = "%s%s:%d"; + private static final int MAX_HOST_ADDRESSES_IN_STRING_VALUE = 5; + private static final String HOST_ADDRESS_DELIMITER = ","; + private static final String HOST_ADDRESSES_PREFIX = "("; + private static final String HOST_ADDRESSES_SUFFIX = ")"; + private static final String TRIMMED_HOST_ADDRESSES_SUFFIX = ",..." + HOST_ADDRESSES_SUFFIX; + + private final Set resolvedAddresses; + private final String stringValue; + + public ResolvedBoltServerAddress( String host, int port, InetAddress[] resolvedAddressesArr ) + { + super( host, port ); + requireNonNull( resolvedAddressesArr, "resolvedAddressesArr" ); + if ( resolvedAddressesArr.length == 0 ) + { + throw new IllegalArgumentException( + "The resolvedAddressesArr must not be empty, check your DomainNameResolver is compliant with the interface contract" ); + } + resolvedAddresses = Collections.unmodifiableSet( new LinkedHashSet<>( Arrays.asList( resolvedAddressesArr ) ) ); + stringValue = createStringRepresentation(); + } + + /** + * Create a stream of unicast addresses. + *

+ * The stream is created from the list of resolved IP addresses. Each unicast address is given a unique IP address as the connectionHost value. + * + * @return stream of unicast addresses. + */ + @Override + public Stream unicastStream() + { + return resolvedAddresses.stream().map( address -> new BoltServerAddress( host, address.getHostAddress(), port ) ); + } + + @Override + public boolean equals( Object o ) + { + if ( this == o ) + { + return true; + } + if ( o == null || getClass() != o.getClass() ) + { + return false; + } + if ( !super.equals( o ) ) + { + return false; + } + ResolvedBoltServerAddress that = (ResolvedBoltServerAddress) o; + return resolvedAddresses.equals( that.resolvedAddresses ); + } + + @Override + public int hashCode() + { + return Objects.hash( super.hashCode(), resolvedAddresses ); + } + + @Override + public String toString() + { + return stringValue; + } + + private String createStringRepresentation() + { + String hostAddresses = resolvedAddresses.stream() + .limit( MAX_HOST_ADDRESSES_IN_STRING_VALUE ) + .map( InetAddress::getHostAddress ) + .collect( joining( HOST_ADDRESS_DELIMITER, HOST_ADDRESSES_PREFIX, + resolvedAddresses.size() > MAX_HOST_ADDRESSES_IN_STRING_VALUE + ? TRIMMED_HOST_ADDRESSES_SUFFIX + : HOST_ADDRESSES_SUFFIX ) ); + return String.format( HOST_ADDRESSES_FORMAT, host, hostAddresses, port ); + } +} diff --git a/driver/src/main/java/org/neo4j/driver/internal/async/connection/ChannelConnectorImpl.java b/driver/src/main/java/org/neo4j/driver/internal/async/connection/ChannelConnectorImpl.java index 96fd19fb33..0bfe976f1a 100644 --- a/driver/src/main/java/org/neo4j/driver/internal/async/connection/ChannelConnectorImpl.java +++ b/driver/src/main/java/org/neo4j/driver/internal/async/connection/ChannelConnectorImpl.java @@ -27,6 +27,7 @@ import io.netty.resolver.AddressResolverGroup; import java.net.InetSocketAddress; +import java.net.SocketAddress; import org.neo4j.driver.AuthToken; import org.neo4j.driver.AuthTokens; @@ -53,6 +54,7 @@ public class ChannelConnectorImpl implements ChannelConnector private final int connectTimeoutMillis; private final Logging logging; private final Clock clock; + private final DomainNameResolver domainNameResolver; private final AddressResolverGroup addressResolverGroup; public ChannelConnectorImpl( ConnectionSettings connectionSettings, SecurityPlan securityPlan, Logging logging, @@ -73,7 +75,8 @@ public ChannelConnectorImpl( ConnectionSettings connectionSettings, SecurityPlan this.pipelineBuilder = pipelineBuilder; this.logging = requireNonNull( logging ); this.clock = requireNonNull( clock ); - this.addressResolverGroup = new NettyDomainNameResolverGroup( requireNonNull( domainNameResolver ) ); + this.domainNameResolver = requireNonNull( domainNameResolver ); + this.addressResolverGroup = new NettyDomainNameResolverGroup( this.domainNameResolver ); } @Override @@ -83,7 +86,17 @@ public ChannelFuture connect( BoltServerAddress address, Bootstrap bootstrap ) bootstrap.handler( new NettyChannelInitializer( address, securityPlan, connectTimeoutMillis, clock, logging ) ); bootstrap.resolver( addressResolverGroup ); - ChannelFuture channelConnected = bootstrap.connect( address.toSocketAddress() ); + SocketAddress socketAddress; + try + { + socketAddress = new InetSocketAddress( domainNameResolver.resolve( address.connectionHost() )[0], address.port() ); + } + catch ( Throwable t ) + { + socketAddress = InetSocketAddress.createUnresolved( address.connectionHost(), address.port() ); + } + + ChannelFuture channelConnected = bootstrap.connect( socketAddress ); Channel channel = channelConnected.channel(); ChannelPromise handshakeCompleted = channel.newPromise(); diff --git a/driver/src/main/java/org/neo4j/driver/internal/cluster/RediscoveryImpl.java b/driver/src/main/java/org/neo4j/driver/internal/cluster/RediscoveryImpl.java index e73d9b74ad..52c76d784c 100644 --- a/driver/src/main/java/org/neo4j/driver/internal/cluster/RediscoveryImpl.java +++ b/driver/src/main/java/org/neo4j/driver/internal/cluster/RediscoveryImpl.java @@ -21,10 +21,8 @@ import io.netty.util.concurrent.EventExecutorGroup; import java.net.UnknownHostException; -import java.util.Arrays; import java.util.Collection; import java.util.HashSet; -import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -32,7 +30,6 @@ import java.util.concurrent.CompletionException; import java.util.concurrent.CompletionStage; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import org.neo4j.driver.Bookmark; import org.neo4j.driver.Logger; @@ -42,6 +39,7 @@ import org.neo4j.driver.exceptions.ServiceUnavailableException; import org.neo4j.driver.internal.BoltServerAddress; import org.neo4j.driver.internal.DomainNameResolver; +import org.neo4j.driver.internal.ResolvedBoltServerAddress; import org.neo4j.driver.internal.spi.ConnectionPool; import org.neo4j.driver.internal.util.Futures; import org.neo4j.driver.net.ServerAddress; @@ -308,7 +306,7 @@ public List resolve() throws UnknownHostException { try { - resolvedAddresses.addAll( resolveAllByDomainName( BoltServerAddress.from( serverAddress ) ) ); + resolveAllByDomainName( serverAddress ).unicastStream().forEach( resolvedAddresses::add ); } catch ( UnknownHostException e ) { @@ -345,10 +343,13 @@ private BoltServerAddress resolveByDomainNameOrThrowCompletionException( BoltSer { try { - Set resolvedAddresses = resolveAllByDomainName( address ); - routingTable.replaceRouterIfPresent( address, new BoltServerAddress( address.host(), address.port(), resolvedAddresses ) ); - return resolvedAddresses.stream().findFirst().orElseThrow( - () -> new IllegalStateException( "Domain name resolution returned empty result set and has not thrown an exception" ) ); + ResolvedBoltServerAddress resolvedAddress = resolveAllByDomainName( address ); + routingTable.replaceRouterIfPresent( address, resolvedAddress ); + return resolvedAddress.unicastStream() + .findFirst() + .orElseThrow( + () -> new IllegalStateException( + "Unexpected condition, the ResolvedBoltServerAddress must always have at least one unicast address" ) ); } catch ( Throwable e ) { @@ -356,10 +357,8 @@ private BoltServerAddress resolveByDomainNameOrThrowCompletionException( BoltSer } } - private Set resolveAllByDomainName( BoltServerAddress address ) throws UnknownHostException + private ResolvedBoltServerAddress resolveAllByDomainName( ServerAddress address ) throws UnknownHostException { - return Arrays.stream( domainNameResolver.resolve( address.host() ) ) - .map( inetAddress -> new BoltServerAddress( inetAddress.getHostAddress(), address.port() ) ) - .collect( Collectors.toCollection( LinkedHashSet::new ) ); + return new ResolvedBoltServerAddress( address.host(), address.port(), domainNameResolver.resolve( address.host() ) ); } } diff --git a/driver/src/main/java/org/neo4j/driver/internal/cluster/RoutingTableHandlerImpl.java b/driver/src/main/java/org/neo4j/driver/internal/cluster/RoutingTableHandlerImpl.java index 7226ce6685..7605b48ee8 100644 --- a/driver/src/main/java/org/neo4j/driver/internal/cluster/RoutingTableHandlerImpl.java +++ b/driver/src/main/java/org/neo4j/driver/internal/cluster/RoutingTableHandlerImpl.java @@ -108,20 +108,18 @@ else if ( routingTable.isStaleFor( context.mode() ) ) } } - private synchronized void freshClusterCompositionFetched( ClusterCompositionLookupResult composition ) + private synchronized void freshClusterCompositionFetched( ClusterCompositionLookupResult compositionLookupResult ) { try { - routingTable.update( composition.getClusterComposition() ); + routingTable.update( compositionLookupResult.getClusterComposition() ); routingTableRegistry.removeAged(); Set addressesToRetain = new LinkedHashSet<>(); - for ( BoltServerAddress address : routingTableRegistry.allServers() ) - { - addressesToRetain.add( address ); - addressesToRetain.addAll( address.resolved() ); - } - composition.getResolvedInitialRouters().ifPresent( + routingTableRegistry.allServers().stream() + .flatMap( BoltServerAddress::unicastStream ) + .forEach( addressesToRetain::add ); + compositionLookupResult.getResolvedInitialRouters().ifPresent( addresses -> { resolvedInitialRouters.clear(); diff --git a/driver/src/test/java/org/neo4j/driver/internal/cluster/ClusterCompositionTest.java b/driver/src/test/java/org/neo4j/driver/internal/cluster/ClusterCompositionTest.java index 99deaae06c..a89d86a763 100644 --- a/driver/src/test/java/org/neo4j/driver/internal/cluster/ClusterCompositionTest.java +++ b/driver/src/test/java/org/neo4j/driver/internal/cluster/ClusterCompositionTest.java @@ -27,10 +27,10 @@ import java.util.Map; import java.util.Set; -import org.neo4j.driver.internal.BoltServerAddress; -import org.neo4j.driver.internal.InternalRecord; import org.neo4j.driver.Record; import org.neo4j.driver.Value; +import org.neo4j.driver.internal.BoltServerAddress; +import org.neo4j.driver.internal.InternalRecord; import static java.util.Arrays.asList; import static org.hamcrest.Matchers.contains; @@ -38,13 +38,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.neo4j.driver.Values.value; import static org.neo4j.driver.internal.util.ClusterCompositionUtil.A; import static org.neo4j.driver.internal.util.ClusterCompositionUtil.B; import static org.neo4j.driver.internal.util.ClusterCompositionUtil.C; import static org.neo4j.driver.internal.util.ClusterCompositionUtil.D; import static org.neo4j.driver.internal.util.ClusterCompositionUtil.E; import static org.neo4j.driver.internal.util.ClusterCompositionUtil.F; -import static org.neo4j.driver.Values.value; class ClusterCompositionTest { @@ -150,8 +150,8 @@ void parseCorrectRecord() Value[] values = { value( 42L ), value( asList( serversEntry( "READ", A, B ), - serversEntry( "WRITE", C, D ), - serversEntry( "ROUTE", E, F ) ) ) + serversEntry( "WRITE", C, D ), + serversEntry( "ROUTE", E, F ) ) ) }; Record record = new InternalRecord( asList( "ttl", "servers" ), values ); @@ -171,8 +171,8 @@ void parsePreservesOrderOfReaders() Value[] values = { value( 42L ), value( asList( serversEntry( "READ", A, C, E, B, F, D ), - serversEntry( "WRITE" ), - serversEntry( "ROUTE" ) ) ) + serversEntry( "WRITE" ), + serversEntry( "ROUTE" ) ) ) }; Record record = new InternalRecord( asList( "ttl", "servers" ), values ); @@ -189,8 +189,8 @@ void parsePreservesOrderOfWriters() Value[] values = { value( 42L ), value( asList( serversEntry( "READ" ), - serversEntry( "WRITE", C, F, D, A, B, E ), - serversEntry( "ROUTE" ) ) ) + serversEntry( "WRITE", C, F, D, A, B, E ), + serversEntry( "ROUTE" ) ) ) }; Record record = new InternalRecord( asList( "ttl", "servers" ), values ); @@ -207,8 +207,8 @@ void parsePreservesOrderOfRouters() Value[] values = { value( 42L ), value( asList( serversEntry( "READ" ), - serversEntry( "WRITE" ), - serversEntry( "ROUTE", F, D, A, B, C, E ) ) ) + serversEntry( "WRITE" ), + serversEntry( "ROUTE", F, D, A, B, C, E ) ) ) }; Record record = new InternalRecord( asList( "ttl", "servers" ), values ); @@ -220,7 +220,7 @@ void parsePreservesOrderOfRouters() } private static ClusterComposition newComposition( long expirationTimestamp, Set readers, - Set writers, Set routers ) + Set writers, Set routers ) { return new ClusterComposition( expirationTimestamp, readers, writers, routers ); } diff --git a/driver/src/test/java/org/neo4j/driver/internal/cluster/RediscoveryTest.java b/driver/src/test/java/org/neo4j/driver/internal/cluster/RediscoveryTest.java index 80f20af27b..536684547d 100644 --- a/driver/src/test/java/org/neo4j/driver/internal/cluster/RediscoveryTest.java +++ b/driver/src/test/java/org/neo4j/driver/internal/cluster/RediscoveryTest.java @@ -430,7 +430,7 @@ void shouldResolveToIP() throws UnknownHostException verify( resolver, times( 1 ) ).resolve( A ); verify( domainNameResolver, times( 1 ) ).resolve( A.host() ); assertEquals( 1, addresses.size() ); - assertEquals( addresses.get( 0 ), new BoltServerAddress( localhost.getHostAddress(), A.port() ) ); + assertEquals( new BoltServerAddress( A.host(), localhost.getHostAddress(), A.port() ), addresses.get( 0 ) ); } private Rediscovery newRediscovery( BoltServerAddress initialRouter, ClusterCompositionProvider compositionProvider, diff --git a/driver/src/test/java/org/neo4j/driver/internal/net/BoltServerAddressTest.java b/driver/src/test/java/org/neo4j/driver/internal/net/BoltServerAddressTest.java index 5f3af8eede..aa7341582c 100644 --- a/driver/src/test/java/org/neo4j/driver/internal/net/BoltServerAddressTest.java +++ b/driver/src/test/java/org/neo4j/driver/internal/net/BoltServerAddressTest.java @@ -20,7 +20,6 @@ import org.junit.jupiter.api.Test; -import java.net.SocketAddress; import java.net.URI; import org.neo4j.driver.internal.BoltServerAddress; @@ -29,7 +28,6 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.junit.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotSame; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; @@ -50,17 +48,6 @@ void portShouldUseDefaultIfNotSupplied() assertThat( new BoltServerAddress( "localhost" ).port(), equalTo( BoltServerAddress.DEFAULT_PORT ) ); } - @Test - void shouldAlwaysResolveAddress() - { - BoltServerAddress boltAddress = new BoltServerAddress( "localhost" ); - - SocketAddress socketAddress1 = boltAddress.toSocketAddress(); - SocketAddress socketAddress2 = boltAddress.toSocketAddress(); - - assertNotSame( socketAddress1, socketAddress2 ); - } - @Test void shouldHaveCorrectToString() { diff --git a/driver/src/test/java/org/neo4j/driver/util/Neo4jRunner.java b/driver/src/test/java/org/neo4j/driver/util/Neo4jRunner.java index 1b0769e7ab..4db2773451 100644 --- a/driver/src/test/java/org/neo4j/driver/util/Neo4jRunner.java +++ b/driver/src/test/java/org/neo4j/driver/util/Neo4jRunner.java @@ -21,6 +21,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.net.InetSocketAddress; import java.net.StandardSocketOptions; import java.net.URI; import java.nio.channels.SocketChannel; @@ -286,7 +287,8 @@ private ServerStatus serverStatus() { SocketChannel soChannel = SocketChannel.open(); soChannel.setOption( StandardSocketOptions.SO_REUSEADDR, true ); - soChannel.connect( boltAddress().toSocketAddress() ); + BoltServerAddress address = boltAddress(); + soChannel.connect( new InetSocketAddress( address.connectionHost(), address.port() ) ); soChannel.close(); return ServerStatus.ONLINE; } diff --git a/testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests/NewDriver.java b/testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests/NewDriver.java index 258dfe2da3..f1d24aa79f 100644 --- a/testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests/NewDriver.java +++ b/testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests/NewDriver.java @@ -39,9 +39,10 @@ import org.neo4j.driver.internal.DefaultDomainNameResolver; import org.neo4j.driver.internal.DomainNameResolver; import org.neo4j.driver.internal.DriverFactory; +import org.neo4j.driver.internal.SecuritySettings; import org.neo4j.driver.internal.cluster.RoutingSettings; import org.neo4j.driver.internal.retry.RetrySettings; -import org.neo4j.driver.internal.security.SecurityPlanImpl; +import org.neo4j.driver.internal.security.SecurityPlan; import org.neo4j.driver.net.ServerAddressResolver; @Setter @@ -93,7 +94,7 @@ private ServerAddressResolver callbackResolver( TestkitState testkitState ) ResolverResolutionRequired.ResolverResolutionRequiredBody body = ResolverResolutionRequired.ResolverResolutionRequiredBody.builder() .id( callbackId ) - .address( address.toString() ) + .address( String.format( "%s:%d", address.host(), address.port() ) ) .build(); ResolverResolutionRequired response = ResolverResolutionRequired.builder() @@ -129,8 +130,11 @@ private org.neo4j.driver.Driver driver( URI uri, AuthToken authToken, Config con { RoutingSettings routingSettings = RoutingSettings.DEFAULT; RetrySettings retrySettings = RetrySettings.DEFAULT; + SecuritySettings.SecuritySettingsBuilder securitySettingsBuilder = new SecuritySettings.SecuritySettingsBuilder(); + SecuritySettings securitySettings = securitySettingsBuilder.build(); + SecurityPlan securityPlan = securitySettings.createSecurityPlan( uri.getScheme() ); return new DriverFactoryWithDomainNameResolver( domainNameResolver ) - .newInstance( uri, authToken, routingSettings, retrySettings, config, SecurityPlanImpl.insecure() ); + .newInstance( uri, authToken, routingSettings, retrySettings, config, securityPlan ); } @Setter