Commit 2e9385ac authored by Pieter Hintjens's avatar Pieter Hintjens

Merge pull request #631 from jrossi/master

Add the Socket Identity info to the ZAP Messages
parents d485404a 19ca8a0f
......@@ -537,6 +537,14 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
rc = session->write_zap_msg (&msg);
errno_assert (rc == 0);
// identity frame
rc = msg.init_size (options.identity_size);
errno_assert(rc == 0);
memcpy (msg.data (), options.identity, options.identity_size);
msg.set_flags (msg_t::more);
rc = session->write_zap_msg (&msg);
errno_assert (rc == 0);
// Mechanism frame
rc = msg.init_size (5);
errno_assert (rc == 0);
......
......@@ -380,6 +380,14 @@ void zmq::plain_mechanism_t::send_zap_request (const std::string &username,
rc = session->write_zap_msg (&msg);
errno_assert (rc == 0);
// identity frame
rc = msg.init_size (options.identity_size);
errno_assert(rc == 0);
memcpy (msg.data (), options.identity, options.identity_size);
msg.set_flags (msg_t::more);
rc = session->write_zap_msg (&msg);
errno_assert (rc == 0);
// Mechanism frame
rc = msg.init_size (5);
errno_assert (rc == 0);
......
......@@ -28,12 +28,15 @@ static void zap_handler (void *zap)
char *sequence = s_recv (zap);
char *domain = s_recv (zap);
char *address = s_recv (zap);
char *identity = s_recv(zap);
char *mechanism = s_recv (zap);
char *username = s_recv (zap);
char *password = s_recv (zap);
printf("identity: %s\n", identity);
assert (streq (version, "1.0"));
assert (streq (mechanism, "PLAIN"));
assert (streq (identity, "IDENT"));
s_sendmore (zap, version);
s_sendmore (zap, sequence);
......@@ -55,6 +58,7 @@ static void zap_handler (void *zap)
free (sequence);
free (domain);
free (address);
free (identity);
free (mechanism);
free (username);
free (password);
......@@ -115,6 +119,7 @@ int main (void)
// Check PLAIN security
server = zmq_socket (ctx, ZMQ_DEALER);
assert (server);
rc = zmq_setsockopt(server, ZMQ_IDENTITY, "IDENT",6);
client = zmq_socket (ctx, ZMQ_DEALER);
assert (client);
......
......@@ -29,11 +29,13 @@ static void zap_handler (void *zap)
char *sequence = s_recv (zap);
char *domain = s_recv (zap);
char *address = s_recv (zap);
char *identity = s_recv(zap);
char *mechanism = s_recv (zap);
char *client_key = s_recv (zap);
assert (streq (version, "1.0"));
assert (streq (mechanism, "CURVE"));
assert (streq (identity, "IDENT"));
s_sendmore (zap, version);
s_sendmore (zap, sequence);
......@@ -46,6 +48,7 @@ static void zap_handler (void *zap)
free (sequence);
free (domain);
free (address);
free (identity);
free (mechanism);
free (client_key);
......@@ -87,6 +90,8 @@ int main (void)
assert (rc == 0);
rc = zmq_setsockopt (server, ZMQ_CURVE_SECRETKEY, server_secret, 40);
assert (rc == 0);
rc = zmq_setsockopt(server, ZMQ_IDENTITY, "IDENT",6);
assert (rc == 0);
rc = zmq_setsockopt (client, ZMQ_CURVE_SERVERKEY, server_public, 40);
assert (rc == 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment