我已按照http://activemq.apache.org/为ssl上下文配置了[ActiveMQ] RedHat's SSL/TLS Tutorial)。然后我将ActiveMQ / conf目录中的客户端密钥库文件转换为.pem格式。为此,我在Stack Overflow上跟随Converting a Java Keystore into PEM Format。
在两个步骤之后,我尝试使用Eclipse Paho MQTT C Client通过SSL连接到ActiveMQ Broker,但它返回状态-1。
代码如下:
MQTTClient client;
MQTTClient_connectOptions conn_opts =MQTTClient_connectOptions_initializer;
MQTTClient_message pubmsg = MQTTClient_message_initializer;
MQTTClient_deliveryToken token;
MQTTClient_SSLOptions ssl_opts = MQTTClient_SSLOptions_initializer;
int rc;
MQTTClient_create(&client, ADDRESS, CLIENTID,
MQTTCLIENT_PERSISTENCE_NONE, NULL);
conn_opts.keepAliveInterval = 20;
conn_opts.cleansession = 1;
conn_opts.ssl = &ssl_opts;
conn_opts.ssl->keyStore = "amq-client.pem";
conn_opts.ssl->privateKeyPassword = "password";
conn_opts.ssl->enabledCipherSuites = "DEFAULT";
conn_opts.ssl->enableServerCertAuth = 0;
MQTTClient_setCallbacks(client, NULL, connlost, msgarrvd, delivered);
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
{
printf("Failed to connect, return code %d\n", rc);
exit(-1);
}
我的配置有错误吗?
请帮我解决这个问题