Skip to content

Allow to enable SSL in StompConnectionFactory #427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/bundle/config_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ enqueue:
connection_timeout: 1
buffer_size: 1000
lazy: true

# Should be true if you want to use secure connections. False by default
ssl_on: false
rabbitmq_stomp:
host: localhost
port: 61613
Expand Down
5 changes: 4 additions & 1 deletion pkg/stomp/StompConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class StompConnectionFactory implements PsrConnectionFactory
* 'connection_timeout' => 1,
* 'sync' => false,
* 'lazy' => true,
* 'ssl_on' => false,
* ].
*
* or
Expand Down Expand Up @@ -75,7 +76,8 @@ private function establishConnection()
if (false == $this->stomp) {
$config = $this->config;

$uri = 'tcp://'.$config['host'].':'.$config['port'];
$scheme = (true === $config['ssl_on']) ? 'ssl' : 'tcp';
$uri = $scheme.'://'.$config['host'].':'.$config['port'];
$connection = new Connection($uri, $config['connection_timeout']);

$this->stomp = new BufferedStompClient($connection, $config['buffer_size']);
Expand Down Expand Up @@ -134,6 +136,7 @@ private function defaultConfig()
'connection_timeout' => 1,
'sync' => false,
'lazy' => true,
'ssl_on' => false,
];
}
}
1 change: 1 addition & 0 deletions pkg/stomp/Symfony/StompTransportFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function addConfiguration(ArrayNodeDefinition $builder)
->integerNode('connection_timeout')->min(1)->defaultValue(1)->end()
->integerNode('buffer_size')->min(1)->defaultValue(1000)->end()
->booleanNode('lazy')->defaultTrue()->end()
->booleanNode('ssl_on')->defaultFalse()->end()
;
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/stomp/Tests/StompConnectionFactoryConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public static function provideConfigs()
'connection_timeout' => 1,
'sync' => false,
'lazy' => true,
'ssl_on' => false,
],
];

Expand All @@ -79,6 +80,7 @@ public static function provideConfigs()
'connection_timeout' => 1,
'sync' => false,
'lazy' => true,
'ssl_on' => false,
],
];

Expand All @@ -94,6 +96,7 @@ public static function provideConfigs()
'connection_timeout' => 1,
'sync' => false,
'lazy' => true,
'ssl_on' => false,
],
];

Expand All @@ -110,6 +113,7 @@ public static function provideConfigs()
'sync' => true,
'lazy' => false,
'foo' => 'bar',
'ssl_on' => false,
],
];

Expand All @@ -126,6 +130,7 @@ public static function provideConfigs()
'sync' => false,
'lazy' => true,
'foo' => 'bar',
'ssl_on' => false,
],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function testShouldAllowAddConfiguration()
'management_plugin_installed' => false,
'management_plugin_port' => 15672,
'lazy' => true,
'ssl_on' => false,
], $config);
}

Expand Down
1 change: 1 addition & 0 deletions pkg/stomp/Tests/Symfony/StompTransportFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function testShouldAllowAddConfiguration()
'connection_timeout' => 1,
'buffer_size' => 1000,
'lazy' => true,
'ssl_on' => false,
], $config);
}

Expand Down