diff --git a/CHANGELOG.md b/CHANGELOG.md index e64af62d3..e9c40acfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log +## [0.8.5](https://github.com/php-enqueue/enqueue-dev/tree/0.8.5) (2017-11-02) +[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.8.4...0.8.5) + +- Amqp add ssl pass phrase option [\#249](https://github.com/php-enqueue/enqueue-dev/pull/249) ([makasim](https://github.com/makasim)) + +- \[amqp-lib\] Ignore empty ssl options. [\#248](https://github.com/php-enqueue/enqueue-dev/pull/248) ([makasim](https://github.com/makasim)) + +## [0.8.4](https://github.com/php-enqueue/enqueue-dev/tree/0.8.4) (2017-11-01) +[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.8.3...0.8.4) + ## [0.8.3](https://github.com/php-enqueue/enqueue-dev/tree/0.8.3) (2017-11-01) [Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.8.2...0.8.3) diff --git a/README.md b/README.md index a96aac98b..150e674cf 100644 --- a/README.md +++ b/README.md @@ -11,17 +11,58 @@ Features: * [Feature rich](docs/quick_tour.md). * Implements [JMS](https://docs.oracle.com/javaee/7/api/javax/jms/package-summary.html) like transports based on [queue-interop](https://github.com/queue-interop/queue-interop) interfaces. * Supported transports - * AMQP(S) based on [the ext](docs/transport/amqp.md), [bunny](docs/transport/amqp_bunny.md), [the lib](docs/transport/amqp_lib.md) - * [Beanstalk](docs/transport/pheanstalk.md) + * [AMQP(s)](docs/transport/amqp.md) based on [PHP AMQP extension](https://github.com/pdezwart/php-amqp). +[![Build Status](https://travis-ci.org/php-enqueue/amqp-ext.png?branch=master)](https://travis-ci.org/php-enqueue/amqp-ext) +[![Total Downloads](https://poser.pugx.org/enqueue/amqp-ext/d/total.png)](https://packagist.org/packages/enqueue/amqp-ext) +[![Latest Stable Version](https://poser.pugx.org/enqueue/amqp-ext/version.png)](https://packagist.org/packages/enqueue/amqp-ext) + * [AMQP](docs/transport/amqp_bunny.md) based on [bunny](https://github.com/jakubkulhan/bunny). +[![Build Status](https://travis-ci.org/php-enqueue/amqp-bunny.png?branch=master)](https://travis-ci.org/php-enqueue/amqp-bunny) +[![Total Downloads](https://poser.pugx.org/enqueue/amqp-bunny/d/total.png)](https://packagist.org/packages/enqueue/amqp-bunny) +[![Latest Stable Version](https://poser.pugx.org/enqueue/amqp-bunny/version.png)](https://packagist.org/packages/enqueue/amqp-bunny) + * [AMQP(s)](docs/transport/amqp_lib.md) based on [php-amqplib](https://github.com/php-amqplib/php-amqplib). +[![Build Status](https://travis-ci.org/php-enqueue/amqp-lib.png?branch=master)](https://travis-ci.org/php-enqueue/amqp-lib) +[![Total Downloads](https://poser.pugx.org/enqueue/amqp-lib/d/total.png)](https://packagist.org/packages/enqueue/amqp-lib) +[![Latest Stable Version](https://poser.pugx.org/enqueue/amqp-lib/version.png)](https://packagist.org/packages/enqueue/amqp-lib) + * [Beanstalk](docs/transport/pheanstalk.md). +[![Build Status](https://travis-ci.org/php-enqueue/pheanstalk.png?branch=master)](https://travis-ci.org/php-enqueue/pheanstalk) +[![Total Downloads](https://poser.pugx.org/enqueue/pheanstalk/d/total.png)](https://packagist.org/packages/enqueue/pheanstalk) +[![Latest Stable Version](https://poser.pugx.org/enqueue/pheanstalk/version.png)](https://packagist.org/packages/enqueue/pheanstalk) * [STOMP](docs/transport/stomp.md) +[![Build Status](https://travis-ci.org/php-enqueue/stomp.png?branch=master)](https://travis-ci.org/php-enqueue/stomp) +[![Total Downloads](https://poser.pugx.org/enqueue/stomp/d/total.png)](https://packagist.org/packages/enqueue/stomp) +[![Latest Stable Version](https://poser.pugx.org/enqueue/stomp/version.png)](https://packagist.org/packages/enqueue/stomp) * [Amazon SQS](docs/transport/sqs.md) +[![Build Status](https://travis-ci.org/php-enqueue/sqs.png?branch=master)](https://travis-ci.org/php-enqueue/sqs) +[![Total Downloads](https://poser.pugx.org/enqueue/sqs/d/total.png)](https://packagist.org/packages/enqueue/sqs) +[![Latest Stable Version](https://poser.pugx.org/enqueue/sqs/version.png)](https://packagist.org/packages/enqueue/sqs) * [Google PubSub](docs/transport/gps.md) +[![Build Status](https://travis-ci.org/php-enqueue/gps.png?branch=master)](https://travis-ci.org/php-enqueue/gps) +[![Total Downloads](https://poser.pugx.org/enqueue/gps/d/total.png)](https://packagist.org/packages/enqueue/gps) +[![Latest Stable Version](https://poser.pugx.org/enqueue/gps/version.png)](https://packagist.org/packages/enqueue/gps) * [Kafka](docs/transport/kafka.md) +[![Build Status](https://travis-ci.org/php-enqueue/rdkafka.png?branch=master)](https://travis-ci.org/php-enqueue/rdkafka) +[![Total Downloads](https://poser.pugx.org/enqueue/rdkafka/d/total.png)](https://packagist.org/packages/enqueue/rdkafka) +[![Latest Stable Version](https://poser.pugx.org/enqueue/rdkafka/version.png)](https://packagist.org/packages/enqueue/rdkafka) * [Redis](docs/transport/redis.md) +[![Build Status](https://travis-ci.org/php-enqueue/redis.png?branch=master)](https://travis-ci.org/php-enqueue/redis) +[![Total Downloads](https://poser.pugx.org/enqueue/redis/d/total.png)](https://packagist.org/packages/enqueue/redis) +[![Latest Stable Version](https://poser.pugx.org/enqueue/redis/version.png)](https://packagist.org/packages/enqueue/redis) * [Gearman](docs/transport/gearman.md) +[![Build Status](https://travis-ci.org/php-enqueue/gearman.png?branch=master)](https://travis-ci.org/php-enqueue/gearman) +[![Total Downloads](https://poser.pugx.org/enqueue/gearman/d/total.png)](https://packagist.org/packages/enqueue/gearman) +[![Latest Stable Version](https://poser.pugx.org/enqueue/gearman/version.png)](https://packagist.org/packages/enqueue/gearman) * [Doctrine DBAL](docs/transport/dbal.md) +[![Build Status](https://travis-ci.org/php-enqueue/dbal.png?branch=master)](https://travis-ci.org/php-enqueue/dbal) +[![Total Downloads](https://poser.pugx.org/enqueue/dbal/d/total.png)](https://packagist.org/packages/enqueue/dbal) +[![Latest Stable Version](https://poser.pugx.org/enqueue/dbal/version.png)](https://packagist.org/packages/enqueue/dbal) * [Filesystem](docs/transport/filesystem.md) +[![Build Status](https://travis-ci.org/php-enqueue/fs.png?branch=master)](https://travis-ci.org/php-enqueue/fs) +[![Total Downloads](https://poser.pugx.org/enqueue/fs/d/total.png)](https://packagist.org/packages/enqueue/fs) +[![Latest Stable Version](https://poser.pugx.org/enqueue/fs/version.png)](https://packagist.org/packages/enqueue/fs) * [Null](docs/transport/null.md). +[![Build Status](https://travis-ci.org/php-enqueue/null.png?branch=master)](https://travis-ci.org/php-enqueue/null) +[![Total Downloads](https://poser.pugx.org/enqueue/null/d/total.png)](https://packagist.org/packages/enqueue/null) +[![Latest Stable Version](https://poser.pugx.org/enqueue/null/version.png)](https://packagist.org/packages/enqueue/null) * [Symfony bundle](https://github.com/php-enqueue/enqueue-dev/blob/master/docs/bundle/quick_tour.md) * [Magento1 extension](https://github.com/php-enqueue/enqueue-dev/blob/master/docs/magento/quick_tour.md) * [Laravel extension](https://github.com/php-enqueue/enqueue-dev/blob/master/docs/laravel/quick_tour.md) diff --git a/pkg/amqp-lib/AmqpConnectionFactory.php b/pkg/amqp-lib/AmqpConnectionFactory.php index de9de0318..f79295352 100644 --- a/pkg/amqp-lib/AmqpConnectionFactory.php +++ b/pkg/amqp-lib/AmqpConnectionFactory.php @@ -87,19 +87,22 @@ 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(), + 'passphrase' => $this->getConfig()->getSslPassPhrase(), + ], 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-lib/composer.json b/pkg/amqp-lib/composer.json index ac0566d5c..5fbe10e18 100644 --- a/pkg/amqp-lib/composer.json +++ b/pkg/amqp-lib/composer.json @@ -9,7 +9,7 @@ "php-amqplib/php-amqplib": "^2.7@dev", "queue-interop/queue-interop": "^0.6@dev", "queue-interop/amqp-interop": "^0.7@dev", - "enqueue/amqp-tools": "^0.8.4@dev" + "enqueue/amqp-tools": "^0.8.5@dev" }, "require-dev": { "phpunit/phpunit": "~5.4.0", diff --git a/pkg/amqp-tools/ConnectionConfig.php b/pkg/amqp-tools/ConnectionConfig.php index 7fb834011..d4deb1620 100644 --- a/pkg/amqp-tools/ConnectionConfig.php +++ b/pkg/amqp-tools/ConnectionConfig.php @@ -25,6 +25,7 @@ * ssl_cacert - Location of Certificate Authority file on local filesystem which should be used with the verify_peer context option to authenticate the identity of the remote peer. A string. * ssl_cert - Path to local certificate file on filesystem. It must be a PEM encoded file which contains your certificate and private key. A string * ssl_key - Path to local private key file on filesystem in case of separate files for certificate (local_cert) and private key. A string. + * ssl_passphrase - Passphrase with which your local_cert file was encoded. A string * * 2. null - in this case it tries to connect to localhost with default settings * 3. amqp: same as 2. @@ -81,9 +82,10 @@ public function __construct($config = null) 'qos_prefetch_count' => 1, 'ssl_on' => false, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ]; $this->addSupportedScheme('amqp'); @@ -158,6 +160,7 @@ public function parse() $config['ssl_cacert'] = (string) $config['ssl_cacert']; $config['ssl_cert'] = (string) $config['ssl_cert']; $config['ssl_key'] = (string) $config['ssl_key']; + $config['ssl_passphrase'] = (string) $config['ssl_passphrase']; $this->config = $config; @@ -293,7 +296,7 @@ public function isSslVerify() } /** - * @return bool + * @return string */ public function getSslCaCert() { @@ -301,7 +304,7 @@ public function getSslCaCert() } /** - * @return bool + * @return string */ public function getSslCert() { @@ -309,18 +312,26 @@ public function getSslCert() } /** - * @return bool + * @return string */ public function getSslKey() { return $this->getOption('ssl_key'); } + /** + * @return string + */ + public function getSslPassPhrase() + { + return $this->getOption('ssl_passphrase'); + } + /** * @param string $name * @param mixed $default * - * @return bool + * @return mixed */ public function getOption($name, $default = null) { diff --git a/pkg/amqp-tools/Tests/ConnectionConfigTest.php b/pkg/amqp-tools/Tests/ConnectionConfigTest.php index 92b8a4ad4..6fba106ed 100644 --- a/pkg/amqp-tools/Tests/ConnectionConfigTest.php +++ b/pkg/amqp-tools/Tests/ConnectionConfigTest.php @@ -72,9 +72,10 @@ public function testShouldParseEmptyDsnWithDriverSet() 'heartbeat' => 0.0, 'ssl_on' => false, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ], $config->getConfig()); } @@ -102,9 +103,10 @@ public function testShouldParseCustomDsnWithDriverSet() 'heartbeat' => 0.0, 'ssl_on' => false, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ], $config->getConfig()); } @@ -143,9 +145,10 @@ public static function provideConfigs() 'heartbeat' => 0.0, 'ssl_on' => false, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ], ]; @@ -168,9 +171,10 @@ public static function provideConfigs() 'heartbeat' => 0.0, 'ssl_on' => false, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ], ]; @@ -193,9 +197,10 @@ public static function provideConfigs() 'heartbeat' => 0.0, 'ssl_on' => false, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ], ]; @@ -218,9 +223,10 @@ public static function provideConfigs() 'heartbeat' => 0.0, 'ssl_on' => true, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ], ]; @@ -243,9 +249,10 @@ public static function provideConfigs() 'heartbeat' => 0.0, 'ssl_on' => false, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ], ]; @@ -268,9 +275,10 @@ public static function provideConfigs() 'heartbeat' => 0.0, 'ssl_on' => false, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ], ]; @@ -293,9 +301,10 @@ public static function provideConfigs() 'heartbeat' => 23.3, 'ssl_on' => false, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ], ]; @@ -318,9 +327,10 @@ public static function provideConfigs() 'heartbeat' => 0.0, 'ssl_on' => false, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ], ]; @@ -343,9 +353,10 @@ public static function provideConfigs() 'heartbeat' => 0.0, 'ssl_on' => false, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ], ]; @@ -368,9 +379,10 @@ public static function provideConfigs() 'heartbeat' => 0.0, 'ssl_on' => false, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ], ]; @@ -393,9 +405,10 @@ public static function provideConfigs() 'heartbeat' => 0.0, 'ssl_on' => false, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ], ]; @@ -418,9 +431,10 @@ public static function provideConfigs() 'heartbeat' => 0.0, 'ssl_on' => false, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ], ]; @@ -449,9 +463,10 @@ public static function provideConfigs() 'heartbeat' => 0.0, 'ssl_on' => false, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ], ]; @@ -477,9 +492,10 @@ public static function provideConfigs() 'heartbeat' => 0.0, 'ssl_on' => true, 'ssl_verify' => true, - 'ssl_cacert' => null, - 'ssl_cert' => null, - 'ssl_key' => null, + 'ssl_cacert' => '', + 'ssl_cert' => '', + 'ssl_key' => '', + 'ssl_passphrase' => '', ], ]; }