首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >c++客户端如何使用ssl url连接服务器

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

Stack Overflow用户
提问于 2019-05-09 17:19:37
回答 1查看 650关注 0票数 0

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

brokerURI =“故障转移:(ssl://xxxx:61617)”;

auto connectionFactory =新的ActiveMQConnectionFactory(brokerURI);

connectionFactory->setUsername(用户名);

connectionFactory->setPassword(password);

connection = connectionFactory->createConnection();

连接->启动();

我被start函数卡住了,没有抛出任何异常。我也不知道原因。可以给我一个简单的ssl代码连接演示给我学习吗?谢谢。

EN

回答 1

Stack Overflow用户

发布于 2019-05-10 03:23:01

该示例记录了您需要执行的SSL配置,即告诉库密钥存储和信任存储(以及密码)位于何处。

代码语言:javascript
复制
// 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
//
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56056174

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档