[zeromq-dev] CZMQ a requirement for curve and ZeroMQ?

Brian Sellden brian_ls2 at comcast.net
Fri Mar 24 11:40:17 CET 2017


I've done some looking around on this and am just confused about what
support there is for curve without using czmq.  Some references say that the
support for reading/writing certs and such in the C++ ZeroMQ core is not
that great so just use CZMQ.

So perhaps misguided, I attempted to load a secret key from a zcert_t and
stuff it into a zmq::socket_t with setsockopt.  Doing so always throws an
'invalid argument' exception so I guess I just need some guidance.  Here's
my code:


zmq::socket_t newSocket(zmq::context_t &context, int socketType,

const char* endpoint) {

                // Create the socket

                zmq::socket_t socket(context, socketType);


                // Configure as a curve server, Stonehouse.

                int server = 1;

                socket.setsockopt(ZMQ_CURVE_SERVER, &server,

                std::cout << "Configured socket as curve server" <<


                // Read secret key and set on socket.

                zcert_t* cert =

                std::cout << "Loaded keyfile." << std::endl;

                // const byte* secret = zcert_secret_key(cert);

                const char* secret = zcert_secret_txt(cert);

                std::cout << "Retrieved secret key of length " <<

                                                << std::endl;

                socket.setsockopt(ZMQ_CURVE_SECRETKEY, secret,

                std::cout << "Added secret key to socket" << std::endl;



// Bind the socket



                return socket;



And the output is:

Configured socket as curve server

Loaded keyfile.

Retrieved secret key of length 8

terminate called after throwing an instance of 'zmq::error_t'

  what():  Invalid argument


Thanks -




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20170324/c3320b78/attachment.htm>

More information about the zeromq-dev mailing list