# Using network()

### TLS-encryption using network() driver

#### Configuration Files Used

To test the TLS-encryption using network() driver, we will run two instances of syslog-ng. One where we are transmitting data using the public key. And another that will listen for the data on the TLS-encrypted network pipeline and decrypt the same.

***Destination Configuration File (Client)***

```
@version: 3.31
@include "scl.conf"

options {
    stats-freq(10);
    time-reopen(10);
};

source custom
{
    example-msg-generator(
        num(20)
        freq(5)
        template("TLS Message")
    );
};

destination tls_destination {
    network(
        "0.0.0.0" port(1999)
        transport("tls")
        tls( 
            ca_dir("/usr/local/etc/ssl/clientSSL/ca.d")
            )
    );
};

log {
    source(custom);
    destination(tls_destination);
};
```

***Source Configuration File (Server)***

```
@version: 3.31
@include "scl.conf"

options {
    stats-freq(10);
    time-reopen(10);
};

destination console{
    file(/dev/stdout);
};

source tls_source {
    network(
        ip(0.0.0.0) port(1999)
        transport("tls")
        tls(
            ca_dir("/usr/local/etc/ssl/ca.d")
            key-file("/usr/local/etc/ssl/key.d/privkey.pem")
            cert-file("/usr/local/etc/ssl/cert.d/cacert.pem")
            peer-verify(optional-untrusted)
        )
    );
};

log {
    source(tls_source);
    destination(console);
};
```

### Proof

![TLS-encryption testing on the network() driver on macOS (x86)](https://3267548193-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MaZdBoDvCx_0JwOUICk%2F-MdvaFXRziyUwoifuHKA%2F-Mdvswkf6HY7gXfsFBup%2FScreenshot%202021-07-06%20at%203.55.38%20PM.png?alt=media\&token=d2ac8754-ae40-4d89-b190-f03970a8c17c)

![TLS-encryption testing on the network() driver on macOS (ARM)](https://3267548193-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MaZdBoDvCx_0JwOUICk%2F-Meb0Q0HGVB0Vb4hziSt%2F-Meb3xQEypLWF7Ats32Z%2FScreen%20Shot%202021-07-15%20at%201.11.41%20AM.png?alt=media\&token=963dec54-783d-44a0-af19-a1ad54938c6e)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://syslog-macos-testing.gitbook.io/syslog-macos-testing/modules/afsocket/tls-encryption/using-network.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
