From f5d43a8867c3c5759b6a160055c62c672f430c27 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Thu, 2 Nov 2017 13:54:56 +0200 Subject: [PATCH] [amqp-lib] Ignore empty ssl options. --- pkg/amqp-lib/AmqpConnectionFactory.php | 16 +++++++++------- pkg/amqp-tools/ConnectionConfig.php | 8 ++++---- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/pkg/amqp-lib/AmqpConnectionFactory.php b/pkg/amqp-lib/AmqpConnectionFactory.php index de9de0318..7b85c6c73 100644 --- a/pkg/amqp-lib/AmqpConnectionFactory.php +++ b/pkg/amqp-lib/AmqpConnectionFactory.php @@ -87,19 +87,21 @@ private function establishConnection() if (false == $this->connection) { if ($this->config->getOption('stream')) { 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(), + ], function ($value) { return '' !== $value; }); + $con = new AMQPSSLConnection( $this->config->getHost(), $this->config->getPort(), $this->config->getUser(), $this->config->getPass(), $this->config->getVHost(), - [ - '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(), - ], + $sslOptions, [ 'insist' => $this->config->getOption('insist'), 'login_method' => $this->config->getOption('login_method'), diff --git a/pkg/amqp-tools/ConnectionConfig.php b/pkg/amqp-tools/ConnectionConfig.php index 7fb834011..f2b1f42af 100644 --- a/pkg/amqp-tools/ConnectionConfig.php +++ b/pkg/amqp-tools/ConnectionConfig.php @@ -293,7 +293,7 @@ public function isSslVerify() } /** - * @return bool + * @return string */ public function getSslCaCert() { @@ -301,7 +301,7 @@ public function getSslCaCert() } /** - * @return bool + * @return string */ public function getSslCert() { @@ -309,7 +309,7 @@ public function getSslCert() } /** - * @return bool + * @return string */ public function getSslKey() { @@ -320,7 +320,7 @@ public function getSslKey() * @param string $name * @param mixed $default * - * @return bool + * @return mixed */ public function getOption($name, $default = null) {