Job tlstunnel-monitoring
README
Skip to buildsTLStunnel
This is a MirageOS unikernel accepting TLS connections via the public (service) network interface on frontend-port, and proxying them using TCP via the private network interface to backend-ip and backend-port. A client connecting to TLStunnel has to establish a TLS connection, which payload is forwarded to the backend service via TCP.
TLStunnel can be used for load-balancing - using multiple TLStunnel on the frontend doing expensive crypto operations (asymmetrics TLS handshakes and symmetric cryptography) with a single (or multiple) backend-services which communicate via plain TCP.
Security-wise only the TLStunnel needs access to the private key of the X.509 certificate(s). When TLStunnel is configured to do client authentication, only valid clients can access the backend service, limiting the attack surface drastically.
Usage
Executing TLStunnel requires two IP addresses: one is the public facing one, the other is on the private network (where TCP connections are forwarded to). Configuration can be done via a command-line utility on the private network. The X.509 certificate should be available via DNS (see dns-primary-git and dns-letsencrypt-secondary).
Let's consider your public IP address being 1.2.3.4/24 (with default gateway 1.2.3.1). You use 192.168.0.4/24 as your private network. Your DNS server is 1.2.3.5 with the key tlstunnel._update.example.org.
Starting TLStunnel:
$ truncate -s 1m /var/db/tlstunnel
$ solo5-hvt --net:service=tap0 --net:private=tap10 --block:storage=/var/db/tlstunnel -- \
tlstunnel/unikernel/dist/tlstunnel.hvt --ipv4=1.2.3.4/24 --ipv4-gateway=1.2.3.1 \
--private-ipv4=192.168.0.4/24 --domains=example.org \
--dns-server=1.2.3.5 --dns-key=tlstunnel._update.example.org:SHA256:m2gls0y3ZMN4DVKx37x/VoKEdll4J2A9qNIl6JIz2z4= \
--key-seed=ROkD8o/Xrc4ScDdxM8cV1+4eQiWUEul+3I1twW+I15E= \
--key=9Fe92fogykIAPBJZU4FUsmpRsAy6YDajIkdSRs650zM=
Now, once tlstunnel managed to get a certificate via DNS, you can already connect to https://1.2.3.4 and should see the certificate:
$ openssl s_client -connect 1.2.3.4:443
$ curl https://1.2.3.4
To configure TLStunnel's forwarding, where a specified hostname will be
forwarded to an IP address and port pair, you have to use the binary
tlstunnel-client
from the client
subfolder. The communication is
authenticated using the shared secret passed to TLStunnel (--key=secret
).
The configuration is kept in the block device (in a robust way, i.e. on change first the new data is written and afterwards the superblock is updates).
$ cd tlstunnel/client
$ dune build
# Listing all configured hostnames:
$ _build/install/default/bin/tlstunnel-client list --key=9Fe92fogykIAPBJZU4FUsmpRsAy6YDajIkdSRs650zM= -r 192.168.0.4:1234
# Adding a new forward:
$ _build/install/default/bin/tlstunnel-client add --key=9Fe92fogykIAPBJZU4FUsmpRsAy6YDajIkdSRs650zM= -r 192.168.0.4:1234 test.example.org 192.168.0.42 80
# Removing a foward:
$ _build/install/default/bin/tlstunnel-client remove --key=9Fe92fogykIAPBJZU4FUsmpRsAy6YDajIkdSRs650zM= -r 192.168.0.4:1234 test.example.org
Installation from source
To install this unikernel from source, you need to have opam (>= 2.0.0) and ocaml (>= 4.08.0) installed. Also, mirage is required (>= 4.5.0). Please follow the installation instructions.
The following steps will clone this git repository and compile the unikernel:
$ git clone https://github.com/robur-coop/tlstunnel.git
$ cd tlstunnel/unikernel && mirage configure -t <your-favourite-target>
$ make depend
$ make build
Installing as binary
Binaries are available at Reproducible OPAM builds, see Deploying binary MirageOS unikernels and Reproducible MirageOS unikernel builds for details.
Questions?
Please open an issue if you have questions, feature requests, or comments.
Builds
Back to readme- ☑ freebsd-14 2024-12-21 06:07:02Z tlstunnel.hvt
SHA256:84d9dfc2531502a7a3515fd038d3425489199efe34494fc08d3277e85801a086
(6.23MB) - ☑ freebsd-14 2024-12-10 05:16:38Z tlstunnel.hvt
SHA256:248478f0c3ad2245ef0a696ecd8175a23794b304acfa1d8d2a42b4f77c5f73d2
(6.23MB) - ☑ freebsd-14 2024-11-15 03:51:03Z tlstunnel.hvt
SHA256:8cb638b5ce3a0384bf72061b99358cbf73e6882f12ae8e3dd7518e11e18bf076
(6.23MB) - ☑ freebsd-14 2024-11-07 05:21:37Z tlstunnel.hvt
SHA256:c8b4bb993028dc05ed2d32e06a08777733a566ffdccc07d923fcfd215d1b01c4
(6.23MB) - ☑ freebsd-14 2024-10-23 02:46:43Z tlstunnel.hvt
SHA256:0f907e5c345664ee30b2176f05d25474ea763e6a8d7d658c5ef81d4d0d737d6c
(6.23MB) - ☑ freebsd-14 2024-10-14 13:10:52Z tlstunnel.hvt
SHA256:05974bf6fad3012f3486c7a485734f8532f7f3eba075bf3bc9442d67fee7b380
(6.23MB)
Including failed builds here.