mirror of
https://github.com/zeromq/libzmq.git
synced 2025-07-05 18:01:41 +02:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
ccf0e61b77
@ -579,6 +579,20 @@ Default value:: null
|
|||||||
Applicable socket types:: all, when using TCP transport
|
Applicable socket types:: all, when using TCP transport
|
||||||
|
|
||||||
|
|
||||||
|
ZMQ_ZAP_DOMAIN: Retrieve RFC 27 authentication domain
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
The 'ZMQ_ZAP_DOMAIN' option shall retrieve the last ZAP domain set for
|
||||||
|
the socket. The returned value shall be a NULL-terminated string and MAY
|
||||||
|
be empty. The returned size SHALL include the terminating null byte.
|
||||||
|
|
||||||
|
[horizontal]
|
||||||
|
Option value type:: character string
|
||||||
|
Option value unit:: N/A
|
||||||
|
Default value:: not set
|
||||||
|
Applicable socket types:: all, when using TCP transport
|
||||||
|
|
||||||
|
|
||||||
RETURN VALUE
|
RETURN VALUE
|
||||||
------------
|
------------
|
||||||
The _zmq_getsockopt()_ function shall return zero if successful. Otherwise it
|
The _zmq_getsockopt()_ function shall return zero if successful. Otherwise it
|
||||||
|
@ -682,6 +682,22 @@ Default value:: NULL
|
|||||||
Applicable socket types:: all, when using TCP transport
|
Applicable socket types:: all, when using TCP transport
|
||||||
|
|
||||||
|
|
||||||
|
ZMQ_ZAP_DOMAIN: Set RFC 27 authentication domain
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Sets the domain for ZAP (ZMQ RFC 27) authentication. For NULL security (the
|
||||||
|
default on all tcp:// connections), ZAP authentication only happens if you
|
||||||
|
set a non-empty domain. For PLAIN and CURVE security, ZAP requests are always
|
||||||
|
made, if there is a ZAP handler present. See http://rfc.zeromq.org/spec:27
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
[horizontal]
|
||||||
|
Option value type:: character string
|
||||||
|
Option value unit:: N/A
|
||||||
|
Default value:: not set
|
||||||
|
Applicable socket types:: all, when using TCP transport
|
||||||
|
|
||||||
|
|
||||||
ZMQ_CONFLATE: Keep only last message
|
ZMQ_CONFLATE: Keep only last message
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
@ -280,6 +280,7 @@ ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, int optval);
|
|||||||
#define ZMQ_REQ_REQUEST_IDS 52
|
#define ZMQ_REQ_REQUEST_IDS 52
|
||||||
#define ZMQ_REQ_STRICT 53
|
#define ZMQ_REQ_STRICT 53
|
||||||
#define ZMQ_CONFLATE 54
|
#define ZMQ_CONFLATE 54
|
||||||
|
#define ZMQ_ZAP_DOMAIN 55
|
||||||
|
|
||||||
/* Message options */
|
/* Message options */
|
||||||
#define ZMQ_MORE 1
|
#define ZMQ_MORE 1
|
||||||
|
@ -523,8 +523,9 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
|
|||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
|
||||||
// Domain frame
|
// Domain frame
|
||||||
rc = msg.init ();
|
rc = msg.init_size (options.zap_domain.length ());
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
memcpy (msg.data (), options.zap_domain.c_str (), options.zap_domain.length ());
|
||||||
msg.set_flags (msg_t::more);
|
msg.set_flags (msg_t::more);
|
||||||
rc = session->write_zap_msg (&msg);
|
rc = session->write_zap_msg (&msg);
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
@ -44,8 +44,10 @@ zmq::null_mechanism_t::null_mechanism_t (session_base_t *session_,
|
|||||||
zap_request_sent (false),
|
zap_request_sent (false),
|
||||||
zap_reply_received (false)
|
zap_reply_received (false)
|
||||||
{
|
{
|
||||||
const int rc = session->zap_connect ();
|
// NULL mechanism only uses ZAP if there's a domain defined
|
||||||
if (rc == 0)
|
// This prevents ZAP requests on naive sockets
|
||||||
|
if (options.zap_domain.size () > 0
|
||||||
|
&& session->zap_connect () == 0)
|
||||||
zap_connected = true;
|
zap_connected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,8 +184,9 @@ void zmq::null_mechanism_t::send_zap_request ()
|
|||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
|
||||||
// Domain frame
|
// Domain frame
|
||||||
rc = msg.init ();
|
rc = msg.init_size (options.zap_domain.length ());
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
memcpy (msg.data (), options.zap_domain.c_str (), options.zap_domain.length ());
|
||||||
msg.set_flags (msg_t::more);
|
msg.set_flags (msg_t::more);
|
||||||
rc = session->write_zap_msg (&msg);
|
rc = session->write_zap_msg (&msg);
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
@ -205,9 +208,9 @@ void zmq::null_mechanism_t::send_zap_request ()
|
|||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
|
||||||
// Mechanism frame
|
// Mechanism frame
|
||||||
rc = msg.init_size (5);
|
rc = msg.init_size (4);
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
memcpy (msg.data (), "NULL", 5);
|
memcpy (msg.data (), "NULL", 4);
|
||||||
rc = session->write_zap_msg (&msg);
|
rc = session->write_zap_msg (&msg);
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
}
|
}
|
||||||
|
@ -285,6 +285,13 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ZMQ_ZAP_DOMAIN:
|
||||||
|
if (optvallen_ >= 0 && optvallen_ < 256) {
|
||||||
|
zap_domain.assign ((const char *) optval_, optvallen_);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
// If libsodium isn't installed, these options provoke EINVAL
|
// If libsodium isn't installed, these options provoke EINVAL
|
||||||
# ifdef HAVE_LIBSODIUM
|
# ifdef HAVE_LIBSODIUM
|
||||||
case ZMQ_CURVE_SERVER:
|
case ZMQ_CURVE_SERVER:
|
||||||
@ -560,6 +567,14 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ZMQ_ZAP_DOMAIN:
|
||||||
|
if (*optvallen_ >= zap_domain.size () + 1) {
|
||||||
|
memcpy (optval_, zap_domain.c_str (), zap_domain.size () + 1);
|
||||||
|
*optvallen_ = zap_domain.size () + 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
// If libsodium isn't installed, these options provoke EINVAL
|
// If libsodium isn't installed, these options provoke EINVAL
|
||||||
# ifdef HAVE_LIBSODIUM
|
# ifdef HAVE_LIBSODIUM
|
||||||
case ZMQ_CURVE_SERVER:
|
case ZMQ_CURVE_SERVER:
|
||||||
|
@ -123,6 +123,9 @@ namespace zmq
|
|||||||
// If peer is acting as server for PLAIN or CURVE mechanisms
|
// If peer is acting as server for PLAIN or CURVE mechanisms
|
||||||
int as_server;
|
int as_server;
|
||||||
|
|
||||||
|
// ZAP authentication domain
|
||||||
|
std::string zap_domain;
|
||||||
|
|
||||||
// Security credentials for PLAIN mechanism
|
// Security credentials for PLAIN mechanism
|
||||||
std::string plain_username;
|
std::string plain_username;
|
||||||
std::string plain_password;
|
std::string plain_password;
|
||||||
|
@ -368,8 +368,9 @@ void zmq::plain_mechanism_t::send_zap_request (const std::string &username,
|
|||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
|
||||||
// Domain frame
|
// Domain frame
|
||||||
rc = msg.init ();
|
rc = msg.init_size (options.zap_domain.length ());
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
memcpy (msg.data (), options.zap_domain.c_str (), options.zap_domain.length ());
|
||||||
msg.set_flags (msg_t::more);
|
msg.set_flags (msg_t::more);
|
||||||
rc = session->write_zap_msg (&msg);
|
rc = session->write_zap_msg (&msg);
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
@ -49,6 +49,8 @@ static void zap_handler (void *ctx)
|
|||||||
char *address = s_recv (zap);
|
char *address = s_recv (zap);
|
||||||
char *identity = s_recv (zap);
|
char *identity = s_recv (zap);
|
||||||
char *mechanism = s_recv (zap);
|
char *mechanism = s_recv (zap);
|
||||||
|
printf ("CURVE domain=%s address=%s identity=%s mechanism=%s\n",
|
||||||
|
domain, address, identity, mechanism);
|
||||||
uint8_t client_key [32];
|
uint8_t client_key [32];
|
||||||
int size = zmq_recv (zap, client_key, 32, 0);
|
int size = zmq_recv (zap, client_key, 32, 0);
|
||||||
assert (size == 32);
|
assert (size == 32);
|
||||||
|
@ -43,12 +43,11 @@ zap_handler (void *ctx)
|
|||||||
char *identity = s_recv (zap);
|
char *identity = s_recv (zap);
|
||||||
char *mechanism = s_recv (zap);
|
char *mechanism = s_recv (zap);
|
||||||
|
|
||||||
|
printf ("domain=%s address=%s identity=%s mechanism=%s\n",
|
||||||
|
domain, address, identity, mechanism);
|
||||||
assert (streq (version, "1.0"));
|
assert (streq (version, "1.0"));
|
||||||
assert (streq (mechanism, "NULL"));
|
assert (streq (mechanism, "NULL"));
|
||||||
// TODO: null_mechanism.cpp issues ZAP requests for connections other
|
assert (streq (identity, "IDENT"));
|
||||||
// than the expected one. In these cases identity is not set, and the
|
|
||||||
// test fails. We'd expect one ZAP request per real client connection.
|
|
||||||
// assert (streq (identity, "IDENT"));
|
|
||||||
|
|
||||||
s_sendmore (zap, version);
|
s_sendmore (zap, version);
|
||||||
s_sendmore (zap, sequence);
|
s_sendmore (zap, sequence);
|
||||||
@ -82,6 +81,8 @@ int main (void)
|
|||||||
assert (server);
|
assert (server);
|
||||||
int rc = zmq_setsockopt (server, ZMQ_IDENTITY, "IDENT", 6);
|
int rc = zmq_setsockopt (server, ZMQ_IDENTITY, "IDENT", 6);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
|
rc = zmq_setsockopt (server, ZMQ_ZAP_DOMAIN, "TEST", 4);
|
||||||
|
assert (rc == 0);
|
||||||
rc = zmq_bind (server, "tcp://*:9999");
|
rc = zmq_bind (server, "tcp://*:9999");
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
|
|
||||||
|
@ -43,6 +43,8 @@ zap_handler (void *ctx)
|
|||||||
char *mechanism = s_recv (zap);
|
char *mechanism = s_recv (zap);
|
||||||
char *username = s_recv (zap);
|
char *username = s_recv (zap);
|
||||||
char *password = s_recv (zap);
|
char *password = s_recv (zap);
|
||||||
|
printf ("PLAIN domain=%s address=%s identity=%s mechanism=%s\n",
|
||||||
|
domain, address, identity, mechanism);
|
||||||
|
|
||||||
assert (streq (version, "1.0"));
|
assert (streq (version, "1.0"));
|
||||||
assert (streq (mechanism, "PLAIN"));
|
assert (streq (mechanism, "PLAIN"));
|
||||||
|
@ -3,15 +3,12 @@
|
|||||||
|
|
||||||
This file is part of 0MQ.
|
This file is part of 0MQ.
|
||||||
|
|
||||||
This tool generates a keypair for the libzmq CURVE security mechanism,
|
This tool generates a CurveZMQ keypair, as two printable strings you can
|
||||||
and encodes the keypair to give two printable strings that you can use
|
use in configuration files or source code. The encoding uses Z85, which
|
||||||
in configuration files or source code. The encoding uses Z85, which is
|
is a base-85 format that is described in 0MQ RFC 32, and which has an
|
||||||
a base-85 format that is described in 0MQ RFC 32, and which has an
|
implementation in the z85_codec.h source used by this tool. The keypair
|
||||||
implementation in the Z85.c source used by this tool. The keypair
|
|
||||||
always works with the secret key held by one party and the public key
|
always works with the secret key held by one party and the public key
|
||||||
distributed (securely!) to peers wishing to connect to it. CURVE is
|
distributed (securely!) to peers wishing to connect to it.
|
||||||
defined by http://rfc.zeromq.org/spec:25. Z85 is defined by
|
|
||||||
http://rfc.zeromq.org/spec:32.
|
|
||||||
|
|
||||||
0MQ is free software; you can redistribute it and/or modify it under
|
0MQ is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU Lesser General Public License as published by
|
the terms of the GNU Lesser General Public License as published by
|
||||||
@ -40,15 +37,12 @@ int main (void)
|
|||||||
# error "libsodium not built correctly"
|
# error "libsodium not built correctly"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
puts ("This tool generates a keypair for the libzmq CURVE security mechanism,");
|
puts ("This tool generates a CurveZMQ keypair, as two printable strings you can");
|
||||||
puts ("and encodes the keypair to give two printable strings that you can use");
|
puts ("use in configuration files or source code. The encoding uses Z85, which");
|
||||||
puts ("in configuration files or source code. The encoding uses Z85, which is");
|
puts ("is a base-85 format that is described in 0MQ RFC 32, and which has an");
|
||||||
puts ("a base-85 format that is described in 0MQ RFC 32, and which has an");
|
puts ("implementation in the z85_codec.h source used by this tool. The keypair");
|
||||||
puts ("implementation in the Z85.c source used by this tool. The keypair");
|
|
||||||
puts ("always works with the secret key held by one party and the public key");
|
puts ("always works with the secret key held by one party and the public key");
|
||||||
puts ("distributed (securely!) to peers wishing to connect to it. CURVE is");
|
puts ("distributed (securely!) to peers wishing to connect to it.");
|
||||||
puts ("defined by http://rfc.zeromq.org/spec:25. Z85 is defined by");
|
|
||||||
puts ("http://rfc.zeromq.org/spec:32.");
|
|
||||||
|
|
||||||
uint8_t public_key [32];
|
uint8_t public_key [32];
|
||||||
uint8_t secret_key [32];
|
uint8_t secret_key [32];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user