[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [mosquitto-dev] Mosquitto & TLS Problems
|
Hi Alessio,
It's a bit tricky to test that, I don't have your other code. I
presume that you are inheriting from the mosquittopp class, which
means your code should be roughly equivalent to the C:
#include "stdio.h"
#include "openssl/err.h"
#include "openssl/ssl.h"
#include "mosquitto.h"
int main(int argc, char *arg[])
{
struct mosquitto *mosq;
mosquitto_lib_init()
mosq = mosquitto_new("id", true, NULL);
mosquitto_username_pw_set(mosq, "user", "pwd" );
mosquitto_tls_set(mosq, "mosquitto.org.crt", NULL, NULL, NULL, NULL);
mosquitto_tls_opts_set(mosq, SSL_VERIFY_PEER, "tlsv1.2", NULL );
mosquitto_connect(mosq, "test.mosquitto.org", 8883, 60);
return 0;
}
This code produces no errors for me, could you please try it? Save to
e.g. test.c and compile with "gcc -o ssl-test test.c -lmosquitto". If
it works fine, then you can try to isolate where the problem with your
code is. If it fails, then there is perhaps something wrong with
openssl.
If you want us to test your own code, you'll have to provide a
complete test case to be sure.
Cheers,
Roger
On Thu, Sep 24, 2015 at 1:56 PM, alessio troiano <alessio@xxxxxxxx> wrote:
> Hi,
> that's the code:
>
> int MQTTClient::connect( char *host, char *user, char *pwd, int port )
> {
> username_pw_set( user, pwd );
> tls_set( "../../certificate/CA.crt" );
> tls_opts_set( SSL_VERIFY_PEER, "tlsv1.2", NULL );
> mosqpp::mosquittopp::connect( host , port, KEEPALIVE );
> return SUCCESS;
> }
>
> MQTTClient is my class that manage all the operation about MQTT.
> I canceled all result checks to simplify the reading.
>
> Bye,
> Alessio
>
>
>
> On 23 September 2015 at 22:43, Roger Light <roger@xxxxxxxxxx> wrote:
>>
>> Hi Alessio,
>>
>> Hmm, ok. Can you share some simple code that recreates the problem?
>> The simplest code that code generate this problem would be:
>>
>> mosquitto_lib_init();
>> mosq = mosquitto_new("id", true, NULL);
>> mosquitto_connect(mosq, "localhost", 1883, 60);
>>
>> If that fails for you, then I'd ask which version of mosquitto and
>> openssl you are using.
>>
>> Cheers,
>>
>> Roger
>>
>>
>> On Wed, Sep 23, 2015 at 7:10 PM, alessio troiano <alessio@xxxxxxxx> wrote:
>> > Hi Alexandre and Roger,
>> > thank you for your suggestions, but:
>> > 1) there is no problem with ciphers or TLS version, because I
>> > successfully
>> > published with mosquitto_sub using the same parameters that I set in my
>> > application;
>> >
>> > 2) I call mosquitto_lib_init().
>> >
>> > Thank you,
>> > Alessio
>> >
>> > On 22 September 2015 at 17:46, Roger Light <roger@xxxxxxxxxx> wrote:
>> >>
>> >> Hi Alessio,
>> >>
>> >> I imagine you are forgetting to call mosquitto_lib_init() first.
>> >>
>> >> Cheers,
>> >>
>> >> Roger
>> >>
>> >>
>> >> On Tue, Sep 22, 2015 at 4:01 PM, alessio troiano <alessio@xxxxxxxx>
>> >> wrote:
>> >> > Hi all,
>> >> > I trying to develop a mqtt client with server authentication through
>> >> > certificates, but the library tell me "Unable to create TLS context".
>> >> > I tried with mosquitto client and openssl command line tool, and
>> >> > there
>> >> > are
>> >> > no problems connecting to the broker.
>> >> >
>> >> > Can you help me?
>> >> > Thank you
>> >> > AlTro
>> >> >
>> >> > _______________________________________________
>> >> > mosquitto-dev mailing list
>> >> > mosquitto-dev@xxxxxxxxxxx
>> >> > To change your delivery options, retrieve your password, or
>> >> > unsubscribe
>> >> > from
>> >> > this list, visit
>> >> > https://dev.eclipse.org/mailman/listinfo/mosquitto-dev
>> >> _______________________________________________
>> >> mosquitto-dev mailing list
>> >> mosquitto-dev@xxxxxxxxxxx
>> >> To change your delivery options, retrieve your password, or unsubscribe
>> >> from this list, visit
>> >> https://dev.eclipse.org/mailman/listinfo/mosquitto-dev
>> >
>> >
>> >
>> > _______________________________________________
>> > mosquitto-dev mailing list
>> > mosquitto-dev@xxxxxxxxxxx
>> > To change your delivery options, retrieve your password, or unsubscribe
>> > from
>> > this list, visit
>> > https://dev.eclipse.org/mailman/listinfo/mosquitto-dev
>> _______________________________________________
>> mosquitto-dev mailing list
>> mosquitto-dev@xxxxxxxxxxx
>> To change your delivery options, retrieve your password, or unsubscribe
>> from this list, visit
>> https://dev.eclipse.org/mailman/listinfo/mosquitto-dev
>
>
>
> _______________________________________________
> mosquitto-dev mailing list
> mosquitto-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/mosquitto-dev