• No results found

Configuring TLS on the syslog-ng server

In document Syslog Ng v2.0 Guide Admin En (Page 38-41)

4. GNU General Public License

3.2. Configuring TLS on the syslog-ng server

1. Copy the certificate (e.g.,syslog-ng.cert) of the syslog-ng server to the syslog-ng server host, for ex-ample into the/etc/syslog-ng/cert.ddirectory. The certificate must be a valid X.509 certificate in PEM format.

2. Copy the private key (e.g.,ng.key) matching the certificate of the ng server to the syslog-ng server host, for example into the/etc/syslog-ng/key.ddirectory. The key must be in PEM format, and must not be password-protected.

3. Add a source statement to the syslog-ng configuration file that uses the tls(

key_file(key_file_fullpathname) cert_file(cert_file_fullpathname) ) option and specify the key and certificate files. The source must use the source driver (tcp()ortcpv6()) matching the destination driver used by the syslog-ng client.

Example 3.11. A source statement using TLS

The following source receives log messages encrypted using TLS, arriving to the1999/TCP port of any interface of the syslog-ng server.

source demo_tls_source {

tcp(ip(0.0.0.0) port(1999)

tls( key_file("/etc/syslog-ng/key.d/syslog-ng.key") cert_file("/etc/syslog-ng/cert.d/syslog-ng.cert")) ); };

4. Disable mutual authentication for the source by setting the following TLS option in the source statement:

tls( peer_verify(optional-untrusted);

To configure mutual authentication, see Section 3.10, “Mutual authentication using TLS” (p. 25).

Encrypting log messages with TLS

Example 3.12. Disabling mutual authentication

The following source receives log messages encrypted using TLS, arriving to the1999/TCP port of any interface of the syslog-ng server. The identity of the syslog-ng client is not verified.

source demo_tls_source {

tcp(ip(0.0.0.0) port(1999)

tls( key_file("/etc/syslog-ng/key.d/syslog-ng.key") cert_file("/etc/syslog-ng/cert.d/syslog-ng.cert") peer_verify(optional-untrusted)) ); };

Warning

Do not forget to update the certificate and key files when they expire.

For the details of the availabletls()options, see Section 9.7, “TLS options” (p. 119).

3.10. Mutual authentication using TLS

This section describes how to configure mutual authentication between the syslog-ng server and the client using syslog-ng Premium Edition. Configuring mutual authentication is similar to configuring TLS (see Section 3.9,

“Encrypting log messages with TLS” (p. 23)), but the server verifies the identity of the client as well. Therefore, each client must have a certificate, and the server must have the certificate of the CA that issued the certificate of the clients. For the concepts of using TLS in syslog-ng, see Section 2.7, “Secure logging using TLS” (p. 9).

Complete the following steps on every syslog-ng client host:

Procedure 3.3. Configuring TLS on the syslog-ng clients

1. Create an X.509 certificate for the syslog-ng client. Thesubject_alt_nameparameter (or theCommon Nameparameter if the subject_alt_name parameter is empty) must contain the hostname or the IP address (as resolved from the syslog-ng clients and relays) of the client.

2. Copy the certificate (e.g.,client_cert.pem) and the matching private key (e.g.,client.key) to the syslog-ng client host, for example into the/etc/syslog-ng/cert.ddirectory. The certificate must be a valid X.509 certificate in PEM format and must not be password-protected.

3. Copy the CA certificate of the Certificate Authority (e.g.,cacert.pem) that issued the certificate of the syslog-ng server to the syslog-ng client hosts, for example into the/etc/syslog-ng/ca.ddirectory.

Issue the following command on the certificate: openssl x509 -noout -hash -in cacert.pem The result is a hash (e.g.,6d2962a8), a series of alphanumeric characters based on the Distinguished Name of the certificate.

Issue the following command to create a symbolic link to the certificate that uses the hash returned by the previous command and the.0suffix.

ln -s cacert.pem 6d2962a8.0

4. Add a destination statement to the syslog-ng configuration file that uses the tls(

ca_dir(path_to_ca_directory) ) option and specify the directory using the CA certificate. The

Mutual authentication using TLS

destination must use thetcp()ortcpv6()destination driver, and the IP address and port parameters of the driver must point to the syslog-ng server. Include the client's certificate and private key in thetls() options.

Example 3.13. A destination statement mutual authentication

The following destination encrypts the log messages using TLS and sends them to the1999/TCP port of the syslog-ng server having the10.1.2.3IP address. The private key and the certificate file authenticating the client is also specified.

destination demo_tls_destination {

tcp("10.1.2.3" port(1999)

tls( ca_dir("/etc/syslog-ng/ca.d")

key_file("/etc/syslog-ng/key.d/client.key") cert_file("/etc/syslog-ng/cert.d/client_cert.pem")) ); };

5. Include the destination created in Step 2 in a log statement.

Warning

The encrypted connection between the server and the client fails if theCommon Nameor the subject_alt_nameparameter of the server certificate does not the hostname or the IP address (as resolved from the syslog-ng clients and relays) of the server.

Do not forget to update the certificate files when they expire.

Complete the following steps on the syslog-ng server:

Procedure 3.4. Configuring TLS on the syslog-ng server

1. Copy the certificate (e.g.,syslog-ng.cert) of the syslog-ng server to the syslog-ng server host, for ex-ample into the/etc/syslog-ng/cert.ddirectory. The certificate must be a valid X.509 certificate in PEM format.

2. Copy the CA certificate (e.g.,cacert.pem) of the Certificate Authority that issued the certificate of the syslog-ng clients to the syslog-ng server, for example into the/etc/syslog-ng/ca.ddirectory.

Issue the following command on the certificate: openssl x509 -noout -hash -in cacert.pem The result is a hash (e.g.,6d2962a8), a series of alphanumeric characters based on the Distinguished Name of the certificate.

Issue the following command to create a symbolic link to the certificate that uses the hash returned by the previous command and the.0suffix.

ln -s cacert.pem 6d2962a8.0

3. Copy the private key (e.g.,ng.key) matching the certificate of the ng server to the syslog-ng server host, for example into the/etc/syslog-ng/key.ddirectory. The key must be in PEM format, and must not be password-protected.

4. Add a source statement to the syslog-ng configuration file that uses the tls(

key_file(key_file_fullpathname) cert_file(cert_file_fullpathname) ) option and specify the key and certificate files. The source must use the source driver (tcp()ortcpv6()) matching

Mutual authentication using TLS

the destination driver used by the syslog-ng client. Also specify the directory storing the certificate of the CA that issued the client's certificate.

Example 3.14. A source statement using TLS

The following source receives log messages encrypted using TLS, arriving to the1999/TCP port of any interface of the syslog-ng server.

source demo_tls_source {

tcp(ip(0.0.0.0) port(1999)

tls( key_file("/etc/syslog-ng/key.d/syslog-ng.key") cert_file("/etc/syslog-ng/cert.d/syslog-ng.cert") ca_dir("/etc/syslog-ng/ca.d")) ); };

Warning

The encrypted connection between the server and the client fails if theCommon Nameor the subject_alt_nameparameter of the client certificate does not the hostname or the IP address (as resolved from the syslog-ng clients and relays) of the server.

Do not forget to update the certificate and key files when they expire.

For the details of the availabletls()options, see Section 9.7, “TLS options” (p. 119).

3.11. Configuring syslog-ng clients

To configure syslog-ng on a client host, complete the following steps:

In document Syslog Ng v2.0 Guide Admin En (Page 38-41)