Skip to content

Commit

Permalink
amqp-bunny: Add SSL support
Browse files Browse the repository at this point in the history
  • Loading branch information
Zayon committed Nov 15, 2024
1 parent 867d45f commit ba92616
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/amqp-bunny/AmqpConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
}
Expand Down

0 comments on commit ba92616

Please sign in to comment.