28
28
use Laudis \Neo4j \Databags \DriverConfiguration ;
29
29
use Laudis \Neo4j \Databags \SessionConfiguration ;
30
30
use Laudis \Neo4j \Enum \ConnectionProtocol ;
31
+ use Laudis \Neo4j \Enum \SslMode ;
31
32
use Laudis \Neo4j \Neo4j \RoutingTable ;
32
33
use Psr \Http \Message \UriInterface ;
33
34
use Throwable ;
@@ -44,6 +45,9 @@ final class BoltConnectionPool implements ConnectionPoolInterface
44
45
private static array $ connectionCache = [];
45
46
private DriverConfiguration $ driverConfig ;
46
47
48
+ /**
49
+ * @psalm-external-mutation-free
50
+ */
47
51
public function __construct (DriverConfiguration $ driverConfig )
48
52
{
49
53
$ this ->driverConfig = $ driverConfig ;
@@ -98,9 +102,17 @@ public function acquire(
98
102
99
103
private function configureSsl (UriInterface $ uri , UriInterface $ server , StreamSocket $ socket , ?RoutingTable $ table ): void
100
104
{
101
- $ scheme = $ uri ->getScheme ();
102
- $ explosion = explode ('+ ' , $ scheme , 2 );
103
- $ sslConfig = $ explosion [1 ] ?? '' ;
105
+ $ sslMode = $ this ->driverConfig ->getSslConfiguration ()->getMode ();
106
+ $ sslConfig = '' ;
107
+ if ($ sslMode === SslMode::FROM_URL ()) {
108
+ $ scheme = $ uri ->getScheme ();
109
+ $ explosion = explode ('+ ' , $ scheme , 2 );
110
+ $ sslConfig = $ explosion [1 ] ?? '' ;
111
+ } elseif ($ sslMode === SslMode::ENABLE ()) {
112
+ $ sslConfig = 's ' ;
113
+ } elseif ($ sslMode === SslMode::ENABLE_WITH_SELF_SIGNED ()) {
114
+ $ sslConfig = 'ssc ' ;
115
+ }
104
116
105
117
if (str_starts_with ($ sslConfig , 's ' )) {
106
118
// We have to pass a different host when working with ssl on aura.
@@ -118,7 +130,7 @@ private function configureSsl(UriInterface $uri, UriInterface $server, StreamSoc
118
130
private function enableSsl (string $ host , string $ sslConfig , StreamSocket $ sock ): void
119
131
{
120
132
$ options = [
121
- 'verify_peer ' => true ,
133
+ 'verify_peer ' => $ this -> driverConfig -> getSslConfiguration ()-> isVerifyPeer () ,
122
134
'peer_name ' => $ host ,
123
135
];
124
136
if (!filter_var ($ host , FILTER_VALIDATE_IP )) {
0 commit comments