activemq-cpp c ++客户端如何使用ssl url连接服务器

时间:2019-05-09 09:19:37

标签: ssl activemq-cpp

我当前正在使用activemq-cpp c ++客户端连接到后端服务器。使用TCP协议时,可以进行通信。我在https://activemq.apache.org/components/cms/example使用上面的示例。但是现在我需要使用SSL协议。我的代码如下:

brokerURI =“ failover:(ssl:// xxxx:61617)”;

auto connectionFactory =新的ActiveMQConnectionFactory(brokerURI);

connectionFactory-> setUsername(用户名);

connectionFactory-> setPassword(password);

connection = connectionFactory-> createConnection();

connection-> start();

我陷入了启动功能,没有抛出任何异常。我不知道为什么能给我一个简单的C ++ SSL代码连接演示供我学习吗?谢谢。

1 个答案:

答案 0 :(得分:0)

[示例] [1]记录了您需要执行的SSL配置,即告诉库密钥存储区和信任存储区(和密码)在何处。

// SSL:
// =========================
// To use SSL you need to specify the location of the trusted Root CA or the
// certificate for the broker you want to connect to.  Using the Root CA allows
// you to use failover with multiple servers all using certificates signed by
// the trusted root.  If using client authentication you also need to specify
// the location of the client Certificate.
//
//     System::setProperty( "decaf.net.ssl.keyStore", "<path>/client.pem" );
//     System::setProperty( "decaf.net.ssl.keyStorePassword", "password" );
//     System::setProperty( "decaf.net.ssl.trustStore", "<path>/rootCA.pem" );
//
// The you just specify the ssl transport in the URI, for example:
//
//     ssl://localhost:61617
//