From 65c4a260f4b6d5efc9b6c1e8fcb10368e3795d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radim=20Vacul=C3=ADk?= Date: Tue, 3 Oct 2023 15:22:24 +0200 Subject: [PATCH] SSL support (#67) --- .docs/README.md | 19 +++++++++++++++++++ src/Connection/Connection.php | 4 +++- src/Connection/ConnectionFactory.php | 3 ++- src/DI/Helpers/ConnectionsHelper.php | 1 + 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.docs/README.md b/.docs/README.md index b2f54fb..4106fd4 100644 --- a/.docs/README.md +++ b/.docs/README.md @@ -81,6 +81,25 @@ tracy: - Contributte\RabbitMQ\Diagnostics\BarPanel ``` +#### SSL configuration + +See examples in [jakubkulhan/bunny documentation](https://github.com/jakubkulhan/bunny/tree/master/examples/ssl). + +```neon +rabbitmq: + connections: + default: + user: guest + password: guest + host: localhost + port: 5672 + lazy: false + ssl: + cafile: 'ca.pem' + allow_self_signed: true + veirfy_peer: true +``` + ### Declaring Queues and Exchanges Since v3.0, all queues and exchanges are by default declared on demand using the console command: diff --git a/src/Connection/Connection.php b/src/Connection/Connection.php index 47086d8..cd18175 100644 --- a/src/Connection/Connection.php +++ b/src/Connection/Connection.php @@ -30,7 +30,8 @@ public function __construct( bool $persistent, string $path, bool $tcpNoDelay, - bool $lazy = false + bool $lazy = false, + ?array $ssl = null ) { $this->connectionParams = [ 'host' => $host, @@ -43,6 +44,7 @@ public function __construct( 'persistent' => $persistent, 'path' => $path, 'tcp_nodelay' => $tcpNoDelay, + 'ssl' => $ssl, ]; $this->bunnyClient = $this->createNewConnection(); diff --git a/src/Connection/ConnectionFactory.php b/src/Connection/ConnectionFactory.php index de53675..8c1eda7 100644 --- a/src/Connection/ConnectionFactory.php +++ b/src/Connection/ConnectionFactory.php @@ -59,7 +59,8 @@ private function create(string $name): IConnection (bool) $connectionData['persistent'], $connectionData['path'], (bool) $connectionData['tcpNoDelay'], - (bool) $connectionData['lazy'] + (bool) $connectionData['lazy'], + $connectionData['ssl'], ); } diff --git a/src/DI/Helpers/ConnectionsHelper.php b/src/DI/Helpers/ConnectionsHelper.php index 8a9d16b..5443dbe 100644 --- a/src/DI/Helpers/ConnectionsHelper.php +++ b/src/DI/Helpers/ConnectionsHelper.php @@ -27,6 +27,7 @@ final class ConnectionsHelper extends AbstractHelper 'path' => '/', 'tcpNoDelay' => false, 'lazy' => false, + 'ssl' => null, ];