Skip to content

Commit 17fd3e9

Browse files
committed
TCP input TLS - Update README.
1 parent b8a6920 commit 17fd3e9

File tree

1 file changed

+151
-0
lines changed

1 file changed

+151
-0
lines changed

src/plugins/input/tcp/README.rst

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ initial period of inability to interpret flow records does not apply here.
1212
Received IPFIX messages may be compressed using LZ4 stream compression. The compression is
1313
enabled on the exporter and the plugin detects it automatically.
1414

15+
Received IPFIX messages may be secured with TLS. The TLS decoder is enabled by specifying the
16+
certificateFile parameter. Inbound TLS messages are automatically detected.
17+
1518
Example configuration
1619
---------------------
1720

@@ -23,6 +26,14 @@ Example configuration
2326
<params>
2427
<localPort>4739</localPort>
2528
<localIPAddress></localIPAddress>
29+
<!-- Uncomment to enable tls
30+
<tls>
31+
<certificateFile>path/to/certificate.crt</certificateFile>
32+
<privateKeyFile>path/to/private.key</privateKeyFile>
33+
<caFile>path/to/ca.crt</caFile>
34+
<verifyPeer>true</verifyPeer>
35+
</tls>
36+
-->
2637
</params>
2738
</input>
2839
@@ -39,7 +50,147 @@ Mandatory parameters:
3950
multiple times (one IP address per occurrence) to manually select multiple interfaces.
4051
[default: empty]
4152

53+
Optional parameters:
54+
55+
:``tls``:
56+
Contains TLS configuration. When this is present, all insecure connections are refused by
57+
default. This can be changed with the parameter ``allowInsecure`` inside of the ``tls`` block.
58+
59+
Tls configuration
60+
-----------------
61+
62+
All paths may be absolute or relative to the cwd of ipfixcol2.
63+
64+
Mandatory parameters:
65+
66+
:``certificateFile``:
67+
Path to a PEM file with certificate.
68+
69+
:``privateKeyFile``:
70+
Path to a PEM file with private key. If this is not present, ``certificateFile`` is expected to
71+
also contain the private key. [default: same as ``certificateFile``]
72+
73+
:``allowInsecure``:
74+
Boolean value. If it is set to true, non-tls connections will be accepted. Otherwise only tls
75+
connections will be accepted. [default: false]
76+
77+
:``verifyPeer``:
78+
Boolean value. If true, ipfixcol as TLS server will verify its clients certificates. Trusted
79+
certificates are set with the following parameters. [default: false]
80+
81+
The following parameters will set the trusted certificates. If the parameter is not present, the
82+
given source type of trusted certificates is not used. If the value is empty, the default is used.
83+
If none of the parameters are present, the defaults will be used for all. Specifying trusted
84+
certificates (certificate authority) is relevant only if the option ``verifyPeer`` is set to true.
85+
86+
:``caFile``:
87+
Path to file with certificate authority. Default uses value from environment variable
88+
``SSL_CERT_FILE`` or uses the system defaults.
89+
90+
:``caDir``:
91+
Path to directory with trusted certificates (certificate authorities). Default uses value from
92+
environment variable ``SSL_CERT_DIR`` or the system defaults.
93+
94+
:``caStore``:
95+
Path to certificate store with trusted certificates (certificate authorities). Default uses
96+
system defaults.
97+
4298
Notes
4399
-----
44100
The LZ4 compression uses special format that compatible with
45101
`ipfixproble <https://github.com/CESNET/ipfixprobe>`.
102+
103+
How to create certificates
104+
--------------------------
105+
106+
Here I describe how to create custom certificates and certificate authorities using
107+
`easyrsa <https://github.com/OpenVPN/easy-rsa>`. This can be done on single machine or two machines
108+
where one is the CA and other has certificate signed by CA.
109+
110+
Go to the path where you want to create the certificate infrastructure.
111+
112+
Download easyrsa and make it executable. This can be done with on both of the machines:
113+
114+
.. code-block:: sh
115+
116+
wget https://raw.githubusercontent.com/OpenVPN/easy-rsa/refs/heads/master/easyrsa3/easyrsa
117+
chmod +x easyrsa
118+
119+
Initialize easyrsa. This will create folder ``pki`` in the current directory with the
120+
infrastructure. This is done on both the system that requests the certificate, and system that signs
121+
the certificate. In case of one system, do this only once.
122+
123+
.. code-block:: sh
124+
125+
./easyrsa init-pki
126+
127+
Create new certificate authority. This will ask you for name of the authority and new password. The
128+
certificate authority will be created at ``pki/ca.crt``. This is done on the system that creates the
129+
certificate.
130+
131+
.. code-block:: sh
132+
133+
./easyrsa build-ca
134+
135+
Create certificate request with a name (``Name``). This is done on the system that requests the
136+
certificate. Often the certificate is used on server which may be addressed in multiple ways. The
137+
certificate needs to be signed for all these names. This is done with the parameter ``--san``
138+
(subject alternative names). The parameter is list of names separated with comma. Each name must
139+
have type. The type may be for example ``IP`` for ip address or ``DNS`` for dns name. Other types
140+
exist. In this example I will set the san to localhost ip address. Creating the certificate request
141+
will ask you for a new password and name of the cretificate. You can leave the name as default and
142+
just press enter. The request file will be created at ``pki/reqs/Name.req`` and the private key will
143+
be created at ``pki/private/Name.key``.
144+
145+
.. code-block:: sh
146+
147+
./easyrsa --san='IP:127.0.0.1' gen-req Name
148+
149+
If the ca system and system requesting certificate are different, copy the request file to the CA
150+
system and import it with this step. If both systems are the same, you can skip this step.
151+
152+
.. code-block:: sh
153+
154+
./easyrsa import-req path/to/request/Name.req Name
155+
156+
Now you can sign the request on the server with the CA. The request is signed for specific use
157+
either as server or client. In this example I will create certificate for server. The option
158+
``--copy-ext`` will make sure to copy the SANs. This will ask you for confirmation and than password
159+
for the CA. If you want to create certificate for client, use ``client`` instead of ``server``. The
160+
certificate will be created at ``pki/issued/Name.crt``.
161+
162+
.. code-block:: sh
163+
164+
./easyrsa --copy-ext sign-req server Name
165+
166+
So right now the important files are on the machines:
167+
168+
:CA machine:
169+
- ``pki/ca.crt`` - certificate of certificate authority.
170+
- ``pki/issued/Name.crt`` - certificate for the other machine.
171+
172+
:other machine:
173+
- ``pki/private/Name.key`` - private key for this machine certificate.
174+
175+
The certificate for the other machine has to be transfered to the other machine. It is no secret so
176+
it doesn't require secure connection. Before you do that, it is good to add the CA certificate to
177+
the certificate of the other machine so that it may send it alongside with its certificate. To do
178+
that, you can just append the contents of ``pki/ca.crt`` to ``pki/issued/Name.crt``. Make sure that
179+
the CA certificate is the second certificate in that file. Now you are free to transfer
180+
``pki/issued/Name.crt`` to the other machine and use it there alongside with its key.
181+
182+
**Inline files:**
183+
184+
The last step also created inline files which may be directly used. Inline file contains the
185+
information in more human readable way alongside with the data itself. The inline files differ
186+
depending on whether you used single machine or multiple machines.
187+
188+
If you used single machine, there will be file ``pki/inline/private/Name.inline``. This file
189+
contains both the machine certificate and CA certificate in correct order and also the private key.
190+
It may be used in place of the certificate file and also in place of the private key file. You don't
191+
have to copy the CA certificate into this file, because it is already here.
192+
193+
If you used multiple machines, there will be file ``pki/inline/Name.inline`` that contains the
194+
machine certificate and CA certificate. The private key is not in this file, because the CA machine
195+
doesn't have it. You can transfer this onto the other machine instead of the crt file and use it in
196+
its place. You don't have to copy the CA certificate into this file, because it is already there.

0 commit comments

Comments
 (0)