Remove TLS related options when not using TLS
This commit is contained in:
parent
a7f8180004
commit
37e602dd28
@ -748,6 +748,27 @@ class ConnectionTest extends TestCase
|
|||||||
$connection = Connection::fromDsn('amqp://localhost?confirm_timeout=0.5', [], $factory);
|
$connection = Connection::fromDsn('amqp://localhost?confirm_timeout=0.5', [], $factory);
|
||||||
$connection->publish('body');
|
$connection->publish('body');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testItCanBeConstructedWithTLSOptionsAndNonTLSDsn()
|
||||||
|
{
|
||||||
|
$this->assertEquals(
|
||||||
|
new Connection([
|
||||||
|
'host' => 'localhost',
|
||||||
|
'port' => 5672,
|
||||||
|
'vhost' => '/',
|
||||||
|
], [
|
||||||
|
'name' => self::DEFAULT_EXCHANGE_NAME,
|
||||||
|
], [
|
||||||
|
self::DEFAULT_EXCHANGE_NAME => [],
|
||||||
|
]),
|
||||||
|
Connection::fromDsn('amqp://', [
|
||||||
|
'cacert' => 'foobar',
|
||||||
|
'cert' => 'foobar',
|
||||||
|
'key' => 'foobar',
|
||||||
|
'verify' => false,
|
||||||
|
])
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestAmqpFactory extends AmqpFactory
|
class TestAmqpFactory extends AmqpFactory
|
||||||
|
@ -219,6 +219,10 @@ class Connection
|
|||||||
return $queueOptions;
|
return $queueOptions;
|
||||||
}, $queuesOptions);
|
}, $queuesOptions);
|
||||||
|
|
||||||
|
if (!$useAmqps) {
|
||||||
|
unset($amqpOptions['cacert'], $amqpOptions['cert'], $amqpOptions['key'], $amqpOptions['verify']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($useAmqps && !self::hasCaCertConfigured($amqpOptions)) {
|
if ($useAmqps && !self::hasCaCertConfigured($amqpOptions)) {
|
||||||
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.');
|
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.');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user