mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-17 08:34:00 +00:00
Merged patch for #1190
This commit is contained in:
parent
88e56365ef
commit
d73b240880
@ -530,20 +530,23 @@ bool zmq::stream_engine_t::handshake ()
|
|||||||
in_batch_size, options.maxmsgsize);
|
in_batch_size, options.maxmsgsize);
|
||||||
alloc_assert (decoder);
|
alloc_assert (decoder);
|
||||||
|
|
||||||
if (memcmp (greeting_recv + 12, "NULL\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 20) == 0) {
|
if (options.mechanism == ZMQ_NULL
|
||||||
|
&& memcmp (greeting_recv + 12, "NULL\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 20) == 0) {
|
||||||
mechanism = new (std::nothrow)
|
mechanism = new (std::nothrow)
|
||||||
null_mechanism_t (session, peer_address, options);
|
null_mechanism_t (session, peer_address, options);
|
||||||
alloc_assert (mechanism);
|
alloc_assert (mechanism);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (memcmp (greeting_recv + 12, "PLAIN\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 20) == 0) {
|
if (options.mechanism == ZMQ_PLAIN
|
||||||
|
&& memcmp (greeting_recv + 12, "PLAIN\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 20) == 0) {
|
||||||
mechanism = new (std::nothrow)
|
mechanism = new (std::nothrow)
|
||||||
plain_mechanism_t (session, peer_address, options);
|
plain_mechanism_t (session, peer_address, options);
|
||||||
alloc_assert (mechanism);
|
alloc_assert (mechanism);
|
||||||
}
|
}
|
||||||
#ifdef HAVE_LIBSODIUM
|
#ifdef HAVE_LIBSODIUM
|
||||||
else
|
else
|
||||||
if (memcmp (greeting_recv + 12, "CURVE\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 20) == 0) {
|
if (options.mechanism == ZMQ_CURVE
|
||||||
|
&& memcmp (greeting_recv + 12, "CURVE\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 20) == 0) {
|
||||||
if (options.as_server)
|
if (options.as_server)
|
||||||
mechanism = new (std::nothrow)
|
mechanism = new (std::nothrow)
|
||||||
curve_server_t (session, peer_address, options);
|
curve_server_t (session, peer_address, options);
|
||||||
|
@ -199,6 +199,26 @@ int main (void)
|
|||||||
expect_bounce_fail (server, client);
|
expect_bounce_fail (server, client);
|
||||||
close_zero_linger (client);
|
close_zero_linger (client);
|
||||||
|
|
||||||
|
// Check CURVE security with NULL client credentials
|
||||||
|
// This must be caught by the curve_server class, not passed to ZAP
|
||||||
|
client = zmq_socket (ctx, ZMQ_DEALER);
|
||||||
|
assert (client);
|
||||||
|
rc = zmq_connect (client, "tcp://localhost:9998");
|
||||||
|
assert (rc == 0);
|
||||||
|
expect_bounce_fail (server, client);
|
||||||
|
close_zero_linger (client);
|
||||||
|
|
||||||
|
// Check CURVE security with PLAIN client credentials
|
||||||
|
// This must be caught by the curve_server class, not passed to ZAP
|
||||||
|
client = zmq_socket (ctx, ZMQ_DEALER);
|
||||||
|
assert (client);
|
||||||
|
rc = zmq_setsockopt (client, ZMQ_PLAIN_USERNAME, "admin", 5);
|
||||||
|
assert (rc == 0);
|
||||||
|
rc = zmq_setsockopt (client, ZMQ_PLAIN_PASSWORD, "password", 8);
|
||||||
|
assert (rc == 0);
|
||||||
|
expect_bounce_fail (server, client);
|
||||||
|
close_zero_linger (client);
|
||||||
|
|
||||||
// Shutdown
|
// Shutdown
|
||||||
rc = zmq_close (server);
|
rc = zmq_close (server);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user