Server side mosquitto c++ implementation

Asked by Charlie F

Hi,

During last months, I've been working and testing some examples using mosquitto 1.2.3 with SSL properties enabled.

Now I have an aplication ( server side) that publish information with mosquitto_pub every "x" seconds. Before publish, I'm using connect function to connect to a mosquitto instance ( launched using terminal (mosquitto -c myConf -p -h ...).

My question is how can I start a mosquitto broker instance without using the command line ( mosquitto -c myConf.conf -p 8883 ... ) ? I want to use c++ code, in order to have, in the same "server side" , the mosquitto instance and the publisher methods ... And then be able to control the conections and new clients certificates with my c++ program...

 My pseudo code :

//ubuntu terminal

mosquitto -c myConf.conf -p 8883 -h localhost -d -v ...

// server side code

MosquittoThread
{
        pWebServer->mp_Mosquitto = new mosqpp::mosquittopp ("MOSQUITTO");

     pWebServer->mp_Mosquitto->tls_opts_set(0,"tlsv1",NULL);
     pWebServer->mp_Mosquitto->tls_set(pWebServer->m_ssl_ca, NULL , pWebServer->m_ssl ,pWebServer->m_ssl_key);
        pWebServer->mp_Mosquitto->connect(pWebServer->host,pWebServer->port,pWebServer->keepalive);
 pWebServer->mp_Mosquitto->loop_start();

}

OnGameStart()
{
    mp_Mosquitto->publish(NULL, m_topic , m_message.size() , m_message );
}

Thanks,

Question information

Language:
English Edit question
Status:
Answered
For:
mosquitto Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Roger Light (roger.light) said :
#1

Hi,

libmosquittopp, which you are using, is purely a client side library.
There is no mosquitto broker library, it is just an executable. This
means you cannot do what you want, assuming I've understood your
question correctly.

Cheers,

Roger

On Tue, Feb 25, 2014 at 2:26 PM, Charlie F
<email address hidden> wrote:
> New question #244550 on mosquitto:
> https://answers.launchpad.net/mosquitto/+question/244550
>
> Hi,
>
> During last months, I've been working and testing some examples using mosquitto 1.2.3 with SSL properties enabled.
>
> Now I have an aplication ( server side) that publish information with mosquitto_pub every "x" seconds. Before publish, I'm using connect function to connect to a mosquitto instance ( launched using terminal (mosquitto -c myConf -p -h ...).
>
> My question is how can I start a mosquitto broker instance without using the command line ( mosquitto -c myConf.conf -p 8883 ... ) ? I want to use c++ code, in order to have, in the same "server side" , the mosquitto instance and the publisher methods ... And then be able to control the conections and new clients certificates with my c++ program...
>
> My pseudo code :
>
> //ubuntu terminal
>
> mosquitto -c myConf.conf -p 8883 -h localhost -d -v ...
>
>
> // server side code
>
> MosquittoThread
> {
> pWebServer->mp_Mosquitto = new mosqpp::mosquittopp ("MOSQUITTO");
>
> pWebServer->mp_Mosquitto->tls_opts_set(0,"tlsv1",NULL);
> pWebServer->mp_Mosquitto->tls_set(pWebServer->m_ssl_ca, NULL , pWebServer->m_ssl ,pWebServer->m_ssl_key);
> pWebServer->mp_Mosquitto->connect(pWebServer->host,pWebServer->port,pWebServer->keepalive);
> pWebServer->mp_Mosquitto->loop_start();
>
> }
>
> OnGameStart()
> {
> mp_Mosquitto->publish(NULL, m_topic , m_message.size() , m_message );
> }
>
>
> Thanks,
>
>
> --
> You received this question notification because you are a member of
> Mosquitto PPA, which is an answer contact for mosquitto.

Revision history for this message
Charlie F (charlieff) said :
#2

Ok, thanks Roger.

What I want to do is check the certificates of the clients and accept only those that have some properties in the subject . Do you have any idea for doing this?

Revision history for this message
Charlie F (charlieff) said :
#3

I'm using mosquitto 1.2.3 and openssl 0.9.8

Revision history for this message
Roger Light (roger.light) said :
#4

Hi Charlie,

That's not currently possible, with the exception that the broker will
check to see whether the client certificate is signed by one of the
trusted certificate authorities.

Cheers,

Roger

On Tue, Feb 25, 2014 at 3:56 PM, Charlie F
<email address hidden> wrote:
> Question #244550 on mosquitto changed:
> https://answers.launchpad.net/mosquitto/+question/244550
>
> Charlie F posted a new comment:
> Ok, thanks Roger.
>
> What I want to do is check the certificates of the clients and accept
> only those that have some properties in the subject . Do you have any
> idea for doing this?
>
> --
> You received this question notification because you are a member of
> Mosquitto PPA, which is an answer contact for mosquitto.

Can you help with this problem?

Provide an answer of your own, or ask Charlie F for more information if necessary.

To post a message you must log in.