tlswrapper(1)
πΈ tlswrapper(1) πΈ
okay bestie, welcome to the manual page for tlswrapper β it lives in section 1 of the General Commands Manual, and it is lowkey one of the most iconic little security freaks you'll ever meet. sit down, grab a snack, we're doing this together π
β¨ NAME β¨
tlswrapper β a TLS encryption wrapper. yes that's the whole name. short, sweet, does exactly what it says on the tin π
β¨ SYNOPSIS β¨
tlswrapper [ options ] prog
β¨ DESCRIPTION β¨
so here's the vibe: tlswrapper is a TLS encryption wrapper that sits between a remote client and a local program called prog. it does not create the connection itself, bestie β that's somebody else's job. Systemd.socket / inetd / tcpserver / ... makes the server connection, and then tlswrapper takes over: it encrypts/decrypts the data stream and reads/writes data from/to the program prog.
like, the whole flow is giving:
Internet <--> systemd.socket/inetd/tcpserver/... <--> tlswrapper <--> prog
no cap, that's the entire architecture. chain of custody, but make it pretty π¦
β¨ OPTIONS β¨
-qβ Quiet mode. no error messages. total silent treatment, but make it a feature π-Qβ Normal mode, and yes this is the default.tlswrapperprints only fatal messages, which means: system errors (like memory allocation problems), configuration errors (like syntax errors), and problems with PEM certificates (missing files, etc...). in this mode,tlswrapperprints nothing about TLS connections. it's giving mysterious. π€«-vβ Verbose mode. nowtlswrapperalso prints information/warnings/errors about the TLS connection β but only after the TLS handshake is successfully done. in this mode, TLS errors that happen before the complete TLS handshake are suppressed. so it's chatty, but only once it trusts you π«Ά-vvβ Debug mode.tlswrapperalso prints debug information about the TLS connection, including all TLS connection warnings/errors. nothing is hidden anymore, she's oversharing and honestly? we love that π-vvvβ Tracing mode.tlswrapperalso prints tracing messages. this is the good stuff, useful for bug hunting π₯-fcertfile β Add a file containing key+certificate(s) in PEM format.-dcertdir β Add a directory containing multiple key+certificate(s) files in PEM format. the file in the directory is selected by the hostname extracted from the SNI extension.
β οΈ Warning: for security reasons, tlswrapper does not allow dots immediately after slashes in the certdir name. it changes these dots to colons before attempting to open the PEM file. yes, it just β¨ rewrites them β¨. that's the security girly behavior.
-aanchorfile β Enable client certificate authentication. use CA trust anchor anchorfile. only one-aoption is supported β she's monogamous π-ccipher β Add symmetric encryption cipher. see ALGORITHMS. default:-c CHACHA20_POLY1305_SHA256 -c AES_256_GCM_SHA384 -c AES_128_GCM_SHA256. and important: the cipher preference depends on the-coption order. order matters, periodt π-eephemeral β Add ephemeral algorithm ephemeral. see ALGORITHMS. default:-e x25519 -e secp256r1. now listen β the algorithm preference currently doesn't depend on the-eoption order. right now we use a fixed preference order:x25519,secp256r1,secp384r1,secp521r1. so yeah, she has a type and it's carved in stone πͺ¨-mβ The minimal TLS version. see ALGORITHMS. (default:tls12).-Mβ The maximal TLS version. see ALGORITHMS. (default:tls12).-tseconds β Set the network timeout to seconds seconds. (default60).-Tseconds β Set the TLS handshake timeout to seconds seconds. (default30).-uuser β Run program prog under a specified user's uid and gid. the account must resolve to non-zero uid and non-zero gid; accounts with uid0or gid0are rejected. root? not on her watch. π«-UASN.1 object β Extract the user from ASN.1 object from the client certificate, and run program prog under the resolved user's uid and gid. certificate-selected accounts must resolve to non-zero uid and non-zero gid; accounts with uid0or gid0are rejected. supported ASN.1 object objects arecommonNameandemailAddress. two options, that's it, pick one bestie π-pversion β Enable incoming proxy-protocol version version string.tlswrapperreceives the proxy-protocol header from the upstream proxy and extracts client connection information. supported versions:1.-sβ Enforce TLS server preferences. (this is the default).-Sβ Don't enforce TLS server preferences.-Jjaildir β Chroot network-process and key-process into a specified jaildir. (default:/var/lib/tlswrapper/empty). yes, the jail cell is literally called empty. iconic π-jjailuser β Run network-process and key-process under a specified jailuser's uid and gid. the account must resolve to non-zero uid and non-zero gid; accounts with uid0or gid0are rejected. if unset, run network-process and key-process under random uid and gid. chaos mode is valid β¨-nβ Enable delayed encryption. this is useful for protocols which use STARTTLS.tlswrapperprovides the child with a control pipe on filedescriptor5for child-to-parent signalling, and a control pipe on filedescriptor6for parent-to-child acknowledgement. the child process starts communication in plaintext, and encryption starts when the child writes a one-byte zero-valued control signal on filedescriptor5, after emitting any protocol-specific cleartext response (for SMTP,220 ready to start TLS\r\n) on the normal data channel.tlswrapperacknowledges the transition with a one-byte zero-valued signal on filedescriptor6. see e.g.tlswrapper-smtp(1). it's giving β¨will they, won't theyβ¨ but for encryption π-Nβ Disable delayed encryption. (this is the default).- prog β program. yeah. that's it. that's the description. she's a woman of few words π
β¨ SECURITY β¨
this section is the main character, honestly. buckle up π§
π Separate process for every connection
tlswrapper is executed from systemd.socket/inetd/tcpserver/..., which runs a separate instance of tlswrapper for each TLS connection.
this ensures that a vulnerability in the code (e.g. a bug in the TLS library) can't be used to compromise the memory of another connection. one bad connection can't drag the whole group chat down π«Ά
π Separate process for network connection and separate process for secret-key operation
to protect against secret-information leaks to the network connection (such as Heartbleed), tlswrapper runs two independent processes for every TLS connection.
one process holds secret-keys and runs secret-keys operations, and the second talks to the network. the processes communicate with each other through UNIX pipes. they're coworkers who never share a desk, and honestly? boundaries. we stan π
π JAIL - Privilege separation, filesystem isolation, limits
the tlswrapper processes run under a dedicated non-zero uid to prohibit kill, ptrace, etc. it's chrooted into an empty, unwritable directory to prohibit filesystem access. it sets ulimits to prohibit new files, sockets, etc. it sets ulimits to prohibit forks.
so many limits. so much self-respect. π
π PEM files
for simplicity, tlswrapper uses both secret-key and certificates in one PEM file.
when the server starts, it runs two independent UNIX processes: one for network communication, and a second for secret-key operations. the network-process is immediately jailed and starts the TLS handshake. the secret-key-process starts under root privileges and waits until the network-process receives the SNI extension from the client-hello packet. then the network-process assembles the PEM filename and sends the name to the secret-key-process. the secret-key-process loads the PEM file, immediately is jailed, and drops its privileges. from here on, both processes run jailed (see JAIL above).
note that PEM files are loaded under root privileges, but parsed in a jailed unprivileged process. this ensures that a vulnerability in the parsing code can't be used to gain root privileges/information. parsing under root is not the vibe, so she simply doesn't. π
β οΈ Warning: for security reasons, tlswrapper does not allow dots immediately after slashes in file names. it changes these dots to colons before attempting to open the PEM file.
π TLS library
tlswrapper uses BearSSL. BearSSL is an implementation of the SSL/TLS protocol (RFC 5246) written in C. it aims at offering the following features:
- Be correct and secure. In particular, insecure protocol versions and choices of algorithms are not supported, by design; cryptographic algorithm implementations are constant-time by default.
- Be small, both in RAM and code footprint. For instance, a minimal server implementation may fit in about 20 kilobytes of compiled code and 25 kilobytes of RAM.
- Be highly portable. BearSSL targets not only big operating systems like Linux and Windows, but also small embedded systems and even special contexts like bootstrap code.
- Be feature-rich and extensible. SSL/TLS has many defined cipher suites and extensions; BearSSL should implement most of them, and allow extra algorithm implementations to be added afterwards, possibly from third parties.
tiny, correct, portable, and extensible? she's literally all of us fr fr π
β¨ ALGORITHMS β¨
okay bestie, let's get into the algorithms part β this is where you pick your TLS vibe. no cap, it's giving very important. π
TLS version (-m option, -M option)
so the TLS versions you can use are:
tls10β that's TLS 1.0, and it's optional π«Άtls11β TLS 1.1, also optional β¨tls12β TLS 1.2, and this one is the default πtls13β TLS 1.3, and bestieβ¦ it's not supported π sorry
ciphers (-c option)
here's the cipher menu, pick your faves:
CHACHA20_POLY1305_SHA256β ChaCha20+Poly1305 encryption (TLS 1.2+) β default π₯AES_256_GCM_SHA384β AES-256/GCM encryption (TLS 1.2+) β default πAES_128_GCM_SHA256β AES-128/GCM encryption (TLS 1.2+) β default β¨AES_256_CBC_SHA384β AES-256/CBC + SHA-384 (TLS 1.2+) β optional πΈAES_128_CBC_SHA256β AES-128/CBC + SHA-256 (TLS 1.2+) β optional π¦AES_256_CBC_SHAβ AES-256/CBC + SHA-1 β optional πAES_128_CBC_SHAβ AES-128/CBC + SHA-1 β optional π
ephemeral (-e option)
and the ephemeral key exchanges β this is the ECDHE tea:
x25519β ECDHE using X25519 β default πsecp256r1β ECDHE using NIST P-256 β default πsecp384r1β ECDHE using NIST P-384 β optional βsecp521r1β ECDHE using NIST P-521 β optional π«
π EXAMPLES π
okay bestie, here's how you actually use this thing. periodt. π
Run tlswrapper using tcpserver/busybox/inetd on port 443.
tcpserver -HRDl0 0 443 tlswrapper [ options ] prog
busybox tcpsvd 0 443 tlswrapper [ options ] prog
inetd.conf line: https stream tcp nowait root /usr/bin/tlswrapper tlswrapper [ options ] prog
Simple usage, use one '/etc/.../rsa.pem' certificate:
... tlswrapper -f '/etc/.../rsa.pem' ...
Use '/etc/.../ecdsa.pem' certificate and fall-back to '/etc/.../rsa.pem' certificate, if the client doesn't support previous one.
... tlswrapper -f '/etc/.../ecdsa.pem' -f '/etc/.../rsa.pem' ...
Use certificate '/etc/.../rsa.d/{hostname}' where {hostname} is extracted from the SNI extension:
... tlswrapper -d '/etc/.../rsa.d/' ...
Use certificate '/etc/.../ecdsa.d/{hostname}' where {hostname} is extracted from the SNI extension, and fall-back to '/etc/.../rsa.d/{hostname}', if the client doesn't support previous one.
... tlswrapper -d '/etc/.../ecdsa.d/' -d '/etc/.../rsa.d/' ...
Use certificate '/etc/.../ecdsa.d/{hostname}' where {hostname} is extracted from the SNI extension, and fall-back to '/etc/.../rsa.pem', if the client doesn't support previous one.
... tlswrapper -d '/etc/.../ecdsa.d/' -f '/etc/.../rsa.pem' ...
Enable TLS 1.0 - TLS 1.2 and all supported algorithms:
... tlswrapper -m tls10 \
-M tls12 \
-c CHACHA20_POLY1305_SHA256 \
-c AES_256_GCM_SHA384 \
-c AES_128_GCM_SHA256 \
-c AES_256_CBC_SHA384 \
-c AES_128_CBC_SHA256 \
-c AES_256_CBC_SHA \
-c AES_128_CBC_SHA \
-e x25519 \
-e secp256r1 \
-e secp384r1 \
-e secp521r1 \
...
Enable TLS 1.0 - TLS 1.2 and all supported algorithms, but different order (prefer AES128):
... tlswrapper -m tls10 \
-M tls12 \
-c CHACHA20_POLY1305_SHA256 \
-c AES_128_GCM_SHA256 \
-c AES_128_CBC_SHA256 \
-c AES_128_CBC_SHA \
-c AES_256_GCM_SHA384 \
-c AES_256_CBC_SHA384 \
-c AES_256_CBC_SHA \
-e x25519 \
-e secp256r1 \
-e secp384r1 \
-e secp521r1 \
...
Enable only 256-bit symmetric ciphers:
... tlswrapper -c CHACHA20_POLY1305_SHA256 \
-c AES_256_GCM_SHA384 \
-c AES_256_CBC_SHA384 \
-c AES_256_CBC_SHA \
...
Enable client certificate authentication:
... tlswrapper -a anchorCA.pem -f rsa.pem ...
Enable client certificate authentication, and run program under user extracted from client cert. from commonName:
... tlswrapper -a anchorCA.pem -U commonName -f rsa.pem ...
Enable client certificate authentication, and run program under user extracted from client cert. from emailAddress:
... tlswrapper -a anchorCA.pem -U emailAddress -f rsa.pem ...
π SEE ALSO π
and that's a wrap, bestie! this was the tlswrapper(1) man page β straight from the source, no date on the footer but we're timeless anyway π
β¨ stay encrypted, stay iconic. π«Άπ
π¦ where this page comes from
- ubuntu stonking: tlswrapper 0~20260501-3 Β· CC0-1.0 OR 0BSD OR MIT-0 OR MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms