Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 7. Security
7.1. Securing connections with SSL/TLS
AMQ C++ uses SSL/TLS to encrypt communication between clients and servers.
To connect to a remote server with SSL/TLS, set the ssl_client_options
connection option and use a connection URL with the amqps
scheme. The ssl_client_options
constructor takes the filename, directory, or database ID of a CA certificate.
Example: Enabling SSL/TLS
proton::ssl_client_options sopts {"/etc/pki/ca-trust"}; proton::connection_options opts {}; opts.ssl_client_options(sopts); container.connect("amqps://example.com", opts);
7.2. Connecting with a user and password
AMQ C++ can authenticate connections with a user and password.
To specify the credentials used for authentication, set the user
and password
options on the connect
method.
Example: Connecting with a user and password
proton::connection_options opts {}; opts.user("alice"); opts.password("secret"); container.connect("amqps://example.com", opts);
7.3. Configuring SASL authentication
AMQ C++ uses the SASL protocol to perform authentication. SASL can use a number of different authentication mechanisms. When two network peers connect, they exchange their allowed mechanisms, and the strongest mechanism allowed by both is selected.
The client uses Cyrus SASL to perform authentication. Cyrus SASL uses plug-ins to support specific SASL mechanisms. Before you can use a particular SASL mechanism, the relevant plug-in must be installed. For example, you need the cyrus-sasl-plain
plug-in in order to use SASL PLAIN authentication.
To see a list of Cyrus SASL plug-ins in Red Hat Enterprise Linux, use the yum search cyrus-sasl
command. To install a Cyrus SASL plug-in, use the yum install PLUG-IN
command.
By default, AMQ C++ allows all of the mechanisms supported by the local SASL library configuration. To restrict the allowed mechanisms and thereby control what mechanisms can be negotiated, use the sasl_allowed_mechs
connection option. This option accepts a string containing a space-separated list of mechanism names.
Example: Configuring SASL authentication
proton::connection_options opts {};
opts.sasl_allowed_mechs("ANONYMOUS");
container.connect("amqps://example.com", opts);
This example forces the connection to authenticate using the ANONYMOUS
mechanism even if the server we connect to offers other options. Valid mechanisms include ANONYMOUS
, PLAIN
, SCRAM-SHA-256
, SCRAM-SHA-1
, GSSAPI
, and EXTERNAL
.
AMQ C++ enables SASL by default. To disable it, set the sasl_enabled
connection option to false.
Example: Disabling SASL
proton::connection_options opts {};
opts.sasl_enabled(false);
container.connect("amqps://example.com", opts);
7.4. Authenticating using Kerberos
Kerberos is a network protocol for centrally managed authentication based on the exchange of encrypted tickets. See Using Kerberos for more information.
- Configure Kerberos in your operating system. See Configuring Kerberos to set up Kerberos on Red Hat Enterprise Linux.
Enable the
GSSAPI
SASL mechanism in your client application.proton::connection_options opts {}; opts.sasl_allowed_mechs("GSSAPI"); container.connect("amqps://example.com", opts);
Use the
kinit
command to authenticate your user credentials and store the resulting Kerberos ticket.$ kinit USER@REALM
- Run the client program.