Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] How to dynamically assign value to ssl.trustStore

Hi,

the truststore parameter should be a file name of a PEM format file containing certificate (chains) to trust, not a URI.  The "const char*" declaration means that the contents of the string are not changed by the library, not that you can't set it.  But it is only a pointer, not allocated memory.

I suggest looking at the samples paho_c_pub and paho_c_sub in https://github.com/eclipse/paho.mqtt.c/tree/master/src/samples to see how that can be used.  In those examples the file name is read from the command line.

There are examples of reading from files in the project, but they are fairly deep down.  I suggest finding a C tutorial on reading/writing files.

On 07/01/2019 08:19, Yoonus wrote:
Hi,

I am using paho C library. I want to connect to SSL enabled broker.

I initialize MQTTClient_connectOptions and MQTTClient_SSLOptions with required values.
I am able to connect to the broker with my settings.

One issue I have is, currently I have directly assigned ssl.trustStore value in the code. Like,
ssl.trustStore = "ssl://<IP Address>:<Port>"

I would like to read the server IP from configuration file.
How can I assign the value read from configuration file to ssl.trustStore?

This variable is defined as "const char* trustStore" in MQTTClient_SSLOptions.
Hence I cannot use strcpy() or other c functions. Any idea how to dynamically assign value to trustStore?

Thanks

_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/paho-dev
-- 
Ian Craggs
icraggs@xxxxxxxxxx                 IBM United Kingdom
Eclipse Paho Project Lead & Mosquitto Committer

Back to the top