11
11
12
12
namespace Laudis \Neo4j \Bolt ;
13
13
14
- use Bolt \connection \StreamSocket ;
15
14
use function count ;
16
15
use function explode ;
17
16
use const FILTER_VALIDATE_IP ;
23
22
24
23
final class SslConfigurator
25
24
{
26
- public function configure (UriInterface $ uri , UriInterface $ server , StreamSocket $ socket , ?RoutingTable $ table , DriverConfiguration $ config ): void
25
+ public function configure (UriInterface $ uri , UriInterface $ server , ?RoutingTable $ table , DriverConfiguration $ config ): ? array
27
26
{
28
27
$ sslMode = $ config ->getSslConfiguration ()->getMode ();
29
28
$ sslConfig = '' ;
@@ -43,14 +42,16 @@ public function configure(UriInterface $uri, UriInterface $server, StreamSocket
43
42
// instance aura deployment, we need to pass the original uri for the
44
43
// ssl configuration to be valid.
45
44
if ($ table && count ($ table ->getWithRole ()) > 1 ) {
46
- $ this ->enableSsl ($ server ->getHost (), $ sslConfig , $ socket , $ config );
47
- } else {
48
- $ this ->enableSsl ($ uri ->getHost (), $ sslConfig , $ socket , $ config );
45
+ return $ this ->enableSsl ($ server ->getHost (), $ sslConfig , $ config );
49
46
}
47
+
48
+ return $ this ->enableSsl ($ uri ->getHost (), $ sslConfig , $ config );
50
49
}
50
+
51
+ return null ;
51
52
}
52
53
53
- private function enableSsl (string $ host , string $ sslConfig , StreamSocket $ sock , DriverConfiguration $ config ): void
54
+ private function enableSsl (string $ host , string $ sslConfig , DriverConfiguration $ config ): ? array
54
55
{
55
56
$ options = [
56
57
'verify_peer ' => $ config ->getSslConfiguration ()->isVerifyPeer (),
@@ -60,10 +61,15 @@ private function enableSsl(string $host, string $sslConfig, StreamSocket $sock,
60
61
$ options ['SNI_enabled ' ] = true ;
61
62
}
62
63
if ($ sslConfig === 's ' ) {
63
- $ sock ->setSslContextOptions ($ options );
64
- } elseif ($ sslConfig === 'ssc ' ) {
64
+ return $ options ;
65
+ }
66
+
67
+ if ($ sslConfig === 'ssc ' ) {
65
68
$ options ['allow_self_signed ' ] = true ;
66
- $ sock ->setSslContextOptions ($ options );
69
+
70
+ return $ options ;
67
71
}
72
+
73
+ return null ;
68
74
}
69
75
}
0 commit comments