Hello,
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,
sizeof(server));
std::cout << "Configured socket as curve server" <<
std::endl;
// Read secret key and set on socket.
zcert_t* cert =
zcert_load("certs/session_logging_daemon.txt_secret");
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 " <<
sizeof(secret)
<< std::endl;
socket.setsockopt(ZMQ_CURVE_SECRETKEY, secret,
sizeof(secret));
std::cout << "Added secret key to socket" << std::endl;
zcert_destroy(&cert);
// Bind the socket
socket.bind(endpoint);
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 -
Brian.
_______________________________________________
zeromq-dev mailing list
[email protected]
https://lists.zeromq.org/mailman/listinfo/zeromq-dev