Skip to content

Commit a30ba41

Browse files
Merge branch 'master' into bolt_v6
2 parents 830d989 + 177d2ce commit a30ba41

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ as received data from database.
171171
$conn = new \Bolt\connection\Socket('127.0.0.1', 7687);
172172
// Create new Bolt instance and provide connection object.
173173
$bolt = new \Bolt\Bolt($conn);
174-
// Set requested protocol versions ..you can add up to 4 versions
174+
// If needed set requested protocol versions ..you can add up to 4 versions
175175
$bolt->setProtocolVersions(5.4);
176176
// Build and get protocol version instance which creates connection and executes handshake.
177177
$protocol = $bolt->build();
@@ -198,7 +198,7 @@ foreach ($protocol->getResponses() as $response) {
198198
}
199199
```
200200

201-
:information_source: Default settings for bolt protocol version is 4.3, 4.4 and 5.0 to 5.8. If you are within this list you can ommit calling `$bolt->setProtocolVersions(5.4);`.
201+
:information_source: Default settings for bolt protocol version is 4.3, 4.4 and 5.0 to 5.8. If you are within this list you can ommit calling `$bolt->setProtocolVersions();`.
202202

203203
### Autoload
204204

@@ -231,20 +231,20 @@ This class extends StreamSocket and adds support for persistent connections. Upo
231231

232232
## :lock: SSL
233233

234+
Connection secured with SSL is available only with connection classes `StreamSocket` and `PStreamSocket`.
235+
234236
### Neo4j Aura
235237

236-
Connecting to Aura requires encryption which is provided with SSL. To connect to Aura you have to use `StreamSocket` connection class and enable SSL.
238+
Connecting to Aura requires encrypted connection by default. To connect to Aura you have to use connection class with SSL support and enable SSL.
237239

238240
```php
239241
$conn = new \Bolt\connection\StreamSocket('helloworld.databases.neo4j.io');
240242
// enable SSL
241-
$conn->setSslContextOptions([
242-
'verify_peer' => true
243-
]);
243+
$conn->setSslContextOptions();
244244
$bolt = new \Bolt\Bolt($conn);
245245
```
246246

247-
https://www.php.net/manual/en/context.ssl.php
247+
_For more informations about what argument can be passed to `setSslContextOptions` check out [php.net](https://www.php.net/manual/en/context.ssl.php)_
248248

249249
### Example on localhost database with self-signed certificate:
250250

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "stefanak-michal/bolt",
33
"description": "PHP library to provide connectivity to graph database over TCP socket with Bolt specification",
44
"keywords": ["neo4j", "bolt", "socket", "database"],
5-
"homepage": "https://github.com/neo4j-php/Bolt",
5+
"homepage": "https://github.com/stefanak-michal/php-bolt-driver",
66
"type": "library",
77
"readme": "README.md",
88
"license": "MIT",
@@ -17,8 +17,8 @@
1717
"phpunit/phpunit": "^9"
1818
},
1919
"support": {
20-
"issues": "https://github.com/neo4j-php/Bolt/issues",
21-
"source": "https://github.com/neo4j-php/Bolt",
20+
"issues": "https://github.com/stefanak-michal/php-bolt-driver/issues",
21+
"source": "https://github.com/stefanak-michal/php-bolt-driver",
2222
"docs": "https://www.neo4j.com/docs/bolt/current/"
2323
},
2424
"funding": [

src/connection/StreamSocket.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
class StreamSocket extends AConnection
1818
{
19-
protected array $sslContextOptions = [];
19+
protected ?array $sslContextOptions = null;
2020

2121
/**
2222
* @var resource
@@ -27,9 +27,11 @@ class StreamSocket extends AConnection
2727

2828
/**
2929
* Set SSL Context options
30+
* Just by calling this method without any argument, SSL will be enabled with default configuration
31+
* @param ?array $options By passing null, SSL will be disabled
3032
* @link https://www.php.net/manual/en/context.ssl.php
3133
*/
32-
public function setSslContextOptions(array $options): void
34+
public function setSslContextOptions(?array $options = []): void
3335
{
3436
$this->sslContextOptions = $options;
3537
}
@@ -40,7 +42,7 @@ public function connect(): bool
4042
'socket' => [
4143
'tcp_nodelay' => true,
4244
],
43-
'ssl' => $this->sslContextOptions
45+
'ssl' => (array)$this->sslContextOptions
4446
]);
4547

4648
$this->stream = @stream_socket_client('tcp://' . $this->ip . ':' . $this->port, $errno, $errstr, $this->timeout, $this->connectionFlags, $context);
@@ -53,7 +55,7 @@ public function connect(): bool
5355
throw new ConnectException('Cannot set socket into blocking mode');
5456
}
5557

56-
if (!empty($this->sslContextOptions)) {
58+
if ($this->sslContextOptions !== null) {
5759
if (stream_socket_enable_crypto($this->stream, true, STREAM_CRYPTO_METHOD_ANY_CLIENT) !== true) {
5860
throw new ConnectException('Enable encryption error');
5961
}

0 commit comments

Comments
 (0)