This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Encrypting log messages with TLS

This section describes how to configure TLS encryption in syslog-ng. For the concepts of using TLS in syslog-ng, see Secure logging using TLS.

1 - Configuring TLS on the AxoSyslog clients

Purpose:

Complete the following steps on every AxoSyslog client host. Examples are provided using both the legacy BSD-syslog protocol (using the network() driver) and the new IETF-syslog protocol standard (using the syslog() driver):

Steps:

  1. Copy the CA certificate (for example, cacert.pem) of the Certificate Authority that issued the certificate of the AxoSyslog server (or the self-signed certificate of the AxoSyslog server) to the AxoSyslog client hosts, for example, into the /opt/syslog-ng/etc/syslog-ng/ca.d directory.

    Issue the following command on the certificate: openssl x509 -noout -hash -in cacert.pem The result is a hash (for example, 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 .0 suffix.

    ln -s cacert.pem 6d2962a8.0

  2. Add a destination statement to the syslog-ng.conf configuration file that uses the tls( ca-dir(path_to_ca_directory) ) option and specify the directory using the CA certificate. The destination must use the network() or the syslog() destination driver, and the IP address and port parameters of the driver must point to the AxoSyslog server.

    Example: A destination statement using TLS

    The following destination encrypts the log messages using TLS and sends them to the 6514/TCP port of the AxoSyslog server having the 10.1.2.3 IP address.

        destination demo_tls_destination {
            network("10.1.2.3" port(6514)
                transport("tls")
                tls( ca_dir("/opt/syslog-ng/etc/syslog-ng/ca.d"))
            );
        };
    

    A similar statement using the IETF-syslog protocol and thus the syslog() driver:

        destination demo_tls_syslog_destination {
            syslog("10.1.2.3" port(6514)
                                transport("tls")
                tls(ca_dir("/opt/syslog-ng/etc/syslog-ng/ca.d"))
            );
        };
    
  3. Include the destination created in Step 2 in a log statement.

2 - Configuring TLS on the AxoSyslog server

Purpose:

Complete the following steps on the AxoSyslog server:

Steps:

  1. Create an X.509 certificate for the AxoSyslog server.

  2. Copy the certificate (for example, syslog-ng.cert) of the AxoSyslog server to the AxoSyslog server host, for example, into the /opt/syslog-ng/etc/syslog-ng/cert.d directory. The certificate must be a valid X.509 certificate in PEM format.

  3. Copy the private key (for example, syslog-ng.key) matching the certificate of the AxoSyslog server to the AxoSyslog server host, for example, into the /opt/syslog-ng/etc/syslog-ng/key.d directory. The key must be in PEM format. If you want to use a password-protected key, see Password-protected keys.

  4. Add a source statement to the syslog-ng.conf 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 (network() or syslog()) matching the destination driver used by the AxoSyslog client.

    Example: A source statement using TLS

    The following source receives log messages encrypted using TLS, arriving to the 1999/TCP port of any interface of the AxoSyslog server.

        source demo_tls_source {
            network(ip(0.0.0.0) port(1999)
                transport("tls")
                tls( 
                    key-file("/opt/syslog-ng/etc/syslog-ng/key.d/syslog-ng.key")
                    cert-file("/opt/syslog-ng/etc/syslog-ng/cert.d/syslog-ng.cert")
                )
            );
        };
    

    A similar source for receiving messages using the IETF-syslog protocol:

        source demo_tls_syslog_source {
            syslog(ip(0.0.0.0) port(1999)
            transport("tls")
            tls(
                key-file("/opt/syslog-ng/etc/syslog-ng/key.d/syslog-ng.key")
                cert-file("/opt/syslog-ng/etc/syslog-ng/cert.d/syslog-ng.cert")
                )
            );
        };
    
  5. Disable mutual authentication for the source by setting the following TLS option in the source statement: tls( peer-verify(optional-untrusted);

    If you want to authenticate the clients, you have to configure mutual authentication. For details, see Mutual authentication using TLS.

    For the details of the available tls() options, see TLS options.

    Example: Disabling mutual authentication

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

        source demo_tls_source {
            network(
                ip(0.0.0.0) port(1999)
                transport("tls")
                tls(
                    key-file("/opt/syslog-ng/etc/syslog-ng/key.d/syslog-ng.key")
                    cert-file("/opt/syslog-ng/etc/syslog-ng/cert.d/syslog-ng.cert")
                    peer-verify(optional-untrusted)
                )
            );
        };
    

    A similar source for receiving messages using the IETF-syslog protocol:

        source demo_tls_syslog_source {
            syslog(
                ip(0.0.0.0) port(1999)
                transport("tls")
                tls(
                    key-file("/opt/syslog-ng/etc/syslog-ng/key.d/syslog-ng.key")
                    cert-file("/opt/syslog-ng/etc/syslog-ng/cert.d/syslog-ng.cert")
                    peer-verify(optional-untrusted)
                )
            );
        };