1
我正在使用openssl使用Eclipse Paho MQTT C客戶端通過TLS連接到一個mosquitto代理。這是我的代碼的一部分:MQTT TLS會話恢復C
MQTTClient client;
MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer;
MQTTClient_message pubmsg = MQTTClient_message_initializer;
MQTTClient_SSLOptions sslOptions = MQTTClient_SSLOptions_initializer;
MQTTClient_deliveryToken token;
int rc;
MQTTClient_create(&client, ADDRESS, CLIENTID,
MQTTCLIENT_PERSISTENCE_NONE, NULL);
conn_opts.keepAliveInterval = 20;
conn_opts.cleansession = 1;
/* TLS */
sslOptions.enableServerCertAuth = 0;
sslOptions.trustStore = "ca_rsp.crt";
conn_opts.ssl = &sslOptions;
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
{
printf("Failed to connect, return code %d\n", rc);
exit(EXIT_FAILURE);
}
其實每次我重新連接到經紀人,客戶端進行完整的握手。我想使用TLS會話恢復來減少開銷。我在網上搜索,但我還沒有找到任何如何以簡單的方式實現的例子。
有什麼建議嗎?
感謝