Skip to content

Commit 812ffa3

Browse files
authored
Merge pull request #427 from arjanvdbos/stomp-ssl-support
Allow to enable SSL in StompConnectionFactory
2 parents d84660c + c3d8628 commit 812ffa3

6 files changed

+15
-1
lines changed

docs/bundle/config_reference.md

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ enqueue:
2121
connection_timeout: 1
2222
buffer_size: 1000
2323
lazy: true
24+
25+
# Should be true if you want to use secure connections. False by default
26+
ssl_on: false
2427
rabbitmq_stomp:
2528
host: localhost
2629
port: 61613

pkg/stomp/StompConnectionFactory.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class StompConnectionFactory implements PsrConnectionFactory
2828
* 'connection_timeout' => 1,
2929
* 'sync' => false,
3030
* 'lazy' => true,
31+
* 'ssl_on' => false,
3132
* ].
3233
*
3334
* or
@@ -75,7 +76,8 @@ private function establishConnection()
7576
if (false == $this->stomp) {
7677
$config = $this->config;
7778

78-
$uri = 'tcp://'.$config['host'].':'.$config['port'];
79+
$scheme = (true === $config['ssl_on']) ? 'ssl' : 'tcp';
80+
$uri = $scheme.'://'.$config['host'].':'.$config['port'];
7981
$connection = new Connection($uri, $config['connection_timeout']);
8082

8183
$this->stomp = new BufferedStompClient($connection, $config['buffer_size']);
@@ -134,6 +136,7 @@ private function defaultConfig()
134136
'connection_timeout' => 1,
135137
'sync' => false,
136138
'lazy' => true,
139+
'ssl_on' => false,
137140
];
138141
}
139142
}

pkg/stomp/Symfony/StompTransportFactory.php

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function addConfiguration(ArrayNodeDefinition $builder)
4343
->integerNode('connection_timeout')->min(1)->defaultValue(1)->end()
4444
->integerNode('buffer_size')->min(1)->defaultValue(1000)->end()
4545
->booleanNode('lazy')->defaultTrue()->end()
46+
->booleanNode('ssl_on')->defaultFalse()->end()
4647
;
4748
}
4849

pkg/stomp/Tests/StompConnectionFactoryConfigTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public static function provideConfigs()
6464
'connection_timeout' => 1,
6565
'sync' => false,
6666
'lazy' => true,
67+
'ssl_on' => false,
6768
],
6869
];
6970

@@ -79,6 +80,7 @@ public static function provideConfigs()
7980
'connection_timeout' => 1,
8081
'sync' => false,
8182
'lazy' => true,
83+
'ssl_on' => false,
8284
],
8385
];
8486

@@ -94,6 +96,7 @@ public static function provideConfigs()
9496
'connection_timeout' => 1,
9597
'sync' => false,
9698
'lazy' => true,
99+
'ssl_on' => false,
97100
],
98101
];
99102

@@ -110,6 +113,7 @@ public static function provideConfigs()
110113
'sync' => true,
111114
'lazy' => false,
112115
'foo' => 'bar',
116+
'ssl_on' => false,
113117
],
114118
];
115119

@@ -126,6 +130,7 @@ public static function provideConfigs()
126130
'sync' => false,
127131
'lazy' => true,
128132
'foo' => 'bar',
133+
'ssl_on' => false,
129134
],
130135
];
131136
}

pkg/stomp/Tests/Symfony/RabbitMqStompTransportFactoryTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public function testShouldAllowAddConfiguration()
5959
'management_plugin_installed' => false,
6060
'management_plugin_port' => 15672,
6161
'lazy' => true,
62+
'ssl_on' => false,
6263
], $config);
6364
}
6465

pkg/stomp/Tests/Symfony/StompTransportFactoryTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function testShouldAllowAddConfiguration()
5555
'connection_timeout' => 1,
5656
'buffer_size' => 1000,
5757
'lazy' => true,
58+
'ssl_on' => false,
5859
], $config);
5960
}
6061

0 commit comments

Comments
 (0)