Job tlstunnel
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-11-21 05:04:01Z tlstunnel.hvt
SHA256:4e41875c4faef0672804969e3f3be5c5d42ba57e77f34bff459c161ff49c1304
(5.93MB) - ☑ freebsd-14 2024-11-15 03:43:29Z tlstunnel.hvt
SHA256:db986d75dfbe2b2108a4b829650758597c0b1628ce959693e65c400c0b40ea9e
(5.93MB) - ☑ freebsd-14 2024-11-07 05:14:02Z tlstunnel.hvt
SHA256:e308ebe0f91901e28a634b476e99894fcb786fbbfe996e649ab1958ada5a025e
(5.93MB) - ☑ freebsd-14 2024-10-23 02:36:42Z tlstunnel.hvt
SHA256:b6abf47f6262fd7ba0a024814128f996f619183b5c6a9784651a3efdb44a1469
(5.93MB) - ☑ freebsd-14 2024-10-14 13:03:30Z tlstunnel.hvt
SHA256:0180dc40e19e4be325cbfefbef796f0915786d44e8b93414b2184e3af2656b69
(5.93MB)
Including failed builds here.