Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » Paho tls of self-signet certificate(Error when try to connect with self-signed certificate)
Paho tls of self-signet certificate [message #1850182] Sun, 20 February 2022 13:08
Yury Blyakher is currently offline Yury BlyakherFriend
Messages: 1
Registered: February 2022
Junior Member
May be you or somebody can help me?
I wrote an application written on C++, that used mqtt as client for publishing some data accepted from hardware sensors. I'm using PAHO library.
Current broker's version used unsecured mqtt ( only password- protected), but now client decides to pass to TLS security.
The only thing that broker needs is certificate ( in mqtt.fx application it call CA certificate file. And when I fill this field by the path to corrent CA file, all works as need)
But I can't understand, what is equivalent to "CA certificate file" in MQTTClient_SSLOptions in PAHO library.
I tried all fields that have char* or const char* type and it is not works. My code: ( I only try to open and do something in this example)

int main()
{
conn_opts = MQTTClient_connectOptions_initializer;
ssl_opts = MQTTClient_SSLOptions_initializer;
pubmsg = MQTTClient_message_initializer;
conn_opts.MQTTVersion =MQTTVERSION_3_1_1;
conn_opts.serverURIcount =0;
conn_opts.serverURIs = NULL;
conn_opts.username="broker username"
conn_opts.password= "broker_psw"
ssl_opts = MQTTClient_SSLOptions_initializer;
ssl_opts.trustStore = "path_to_CA_file";
ssl_opts.sslVersion = 3;
ssl_opts.ssl_error_cb = SSL_err_handler;
conn_opts.ssl = & ssl_opts;
ssl_opts.struct_version =3;
conn_opts.struct_version = 1;
MQTTClient_create(&client, address, clientID, MQTTCLIENT_PERSISTENCE_NONE, NULL );
int rc; if ( (rc = MQTTClient_connect( client, &conn_opts)) != MQTTCLIENT_SUCCESS) { // that is the thing that occurs
printf( "failed to connect, code is %d\n", rc); return rc; }
// do the work
}
Previous Topic:RPi Python MQTT - occasional errors
Next Topic:RUST mqtt-sn crate help
Goto Forum:
  


Current Time: Fri May 03 08:35:23 GMT 2024

Powered by FUDForum. Page generated in 0.03513 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top