Skip to content

Commit 2d8f975

Browse files
Merge branch '5.2' into 5.3
* 5.2: bug #41715: [FrameworkBundle] Partial backport of PR#41530 Fix some typos in Greek language Remove TLS related options when not using TLS
2 parents 4f89ce3 + 76e75fa commit 2d8f975

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Tests/Transport/ConnectionTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,27 @@ public function testItCanPublishAndWaitForConfirmation()
764764
$connection->publish('body');
765765
}
766766

767+
public function testItCanBeConstructedWithTLSOptionsAndNonTLSDsn()
768+
{
769+
$this->assertEquals(
770+
new Connection([
771+
'host' => 'localhost',
772+
'port' => 5672,
773+
'vhost' => '/',
774+
], [
775+
'name' => self::DEFAULT_EXCHANGE_NAME,
776+
], [
777+
self::DEFAULT_EXCHANGE_NAME => [],
778+
]),
779+
Connection::fromDsn('amqp://', [
780+
'cacert' => 'foobar',
781+
'cert' => 'foobar',
782+
'key' => 'foobar',
783+
'verify' => false,
784+
])
785+
);
786+
}
787+
767788
private function createDelayOrRetryConnection(\AMQPExchange $delayExchange, string $deadLetterExchangeName, string $delayQueueName): Connection
768789
{
769790
$amqpConnection = $this->createMock(\AMQPConnection::class);

Transport/Connection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ public static function fromDsn(string $dsn, array $options = [], AmqpFactory $am
224224
return $queueOptions;
225225
}, $queuesOptions);
226226

227+
if (!$useAmqps) {
228+
unset($amqpOptions['cacert'], $amqpOptions['cert'], $amqpOptions['key'], $amqpOptions['verify']);
229+
}
230+
227231
if ($useAmqps && !self::hasCaCertConfigured($amqpOptions)) {
228232
throw new InvalidArgumentException('No CA certificate has been provided. Set "amqp.cacert" in your php.ini or pass the "cacert" parameter in the DSN to use SSL. Alternatively, you can use amqp:// to use without SSL.');
229233
}

0 commit comments

Comments
 (0)