From ba92616bc47ce7a35902cdf31b754dfeb8bd103e Mon Sep 17 00:00:00 2001 From: Pablo Godinez <Zayon@users.noreply.github.com> Date: Fri, 15 Nov 2024 10:37:52 +0000 Subject: [PATCH] amqp-bunny: Add SSL support --- pkg/amqp-bunny/AmqpConnectionFactory.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pkg/amqp-bunny/AmqpConnectionFactory.php b/pkg/amqp-bunny/AmqpConnectionFactory.php index 241929abe..84ba4ea39 100644 --- a/pkg/amqp-bunny/AmqpConnectionFactory.php +++ b/pkg/amqp-bunny/AmqpConnectionFactory.php @@ -74,10 +74,6 @@ public function getConfig(): ConnectionConfig private function establishConnection(): BunnyClient { - if ($this->config->isSslOn()) { - throw new \LogicException('The bunny library does not support SSL connections'); - } - if (false == $this->client) { $bunnyConfig = []; $bunnyConfig['host'] = $this->config->getHost(); @@ -102,6 +98,20 @@ private function establishConnection(): BunnyClient $bunnyConfig['tcp_nodelay'] = $this->config->getOption('tcp_nodelay'); } + if ($this->config->isSslOn()) { + $sslOptions = array_filter([ + 'cafile' => $this->config->getSslCaCert(), + 'local_cert' => $this->config->getSslCert(), + 'local_pk' => $this->config->getSslKey(), + 'verify_peer' => $this->config->isSslVerify(), + 'verify_peer_name' => $this->config->isSslVerify(), + 'passphrase' => $this->getConfig()->getSslPassPhrase(), + 'ciphers' => $this->config->getOption('ciphers', ''), + ], function ($value) { return '' !== $value; }); + + $bunnyConfig['ssl'] = $sslOptions; + } + $this->client = new BunnyClient($bunnyConfig); $this->client->connect(); }