Hi Alan,

Yes, I'm pleased to say that it works. For those interested, here's how I
did it:

Derive from io::socket_engine and reimplement io_read and io_write. Just
make them call through to curl_easy_recv and curl_easy_send respectively.
Make sure you construct your class derived from socket engine with the
constructor that just takes a file descriptor (rather than the URL one).

In setting up the socket you'll need to do the following:

        curl_easy_setopt(m_easy, CURLOPT_URL, m_url.c_str());
        curl_easy_setopt(m_easy, CURLOPT_CONNECT_ONLY, 1L);

I'm using a curl_multi to contain a number of curl_easy, so that the
connection can be established asynchronously. If you also choose this
approach, then you'll need so define socket and timer callback functions:

    curl_multi_setopt(m_multi, CURLMOPT_SOCKETFUNCTION, staticOnSocket);
    curl_multi_setopt(m_multi, CURLMOPT_SOCKETDATA, this);
    curl_multi_setopt(m_multi, CURLMOPT_TIMERFUNCTION,
staticOnTimerRequest);
    curl_multi_setopt(m_multi, CURLMOPT_TIMERDATA, this);

In these callbacks do the usual curl_multi_socket_action, and then iterate
over the list of messages returned (if any). When you get CURLMSG_DONE, then
you can get the socket file descriptor using curl_easy_getinfo(m_easy,
CURLINFO_ACTIVESOCKET, &m_fd);

Now you have your socket, and libcurl will have done all the SSL
negotiations. You can just create an instance of your class derived from
io::socket_engine using the socket and everything should spring into life.

One other thing worth mentioning is that you have to fiddle the URL a little
for the amqps case.
When it's just straight amqp, just strip then scheme from the proton::url
before passing it to libcurl (i.e. amqp://my.domain.place:PORT ->
my.domain.place:PORT)
When it's amqps you'll need to trick libcurl into thinking it's https (i.e.
amqps://my.domain.place:PORT -> https://my.domain.place:PORT)

Hope this helps anyone else trying to achieve SSL connections with the
connection_engine model.

Toby




--
View this message in context: 
http://qpid.2158936.n2.nabble.com/qpid-proton-0-12-2-connection-engine-and-ssl-tp7647090p7647560.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to