dhi.io/ktls-utils
Handshake service for kernel TLS consumers
All examples in this guide use the public image. If you've mirrored the repository for your own use (for example, to your Docker Hub namespace), update your commands to reference the mirrored image instead of the public one.
For example:
dhi.io/<repository>:<tag><your-namespace>/dhi-<repository>:<tag>For the examples, you must first use docker login dhi.io to authenticate to the registry to pull the images.
Run the following command to start tlshd. Replace <tag> with the image variant you want to run.
docker run -d --name tlshd \
--privileged \
--network host \
dhi.io/ktls-utils:<tag>
Important notes:
--privileged flag is required because tlshd needs to interact with kernel netlink sockets and manage kernel TLS
sessions--network host flag is typically required because tlshd operates on kernel sockets/etc/tlshd for custom configurationStart tlshd with a minimal /etc/tlshd/config configuration file:
# Create a minimal config
mkdir -p /etc/tlshd
cat > /etc/tlshd/config << 'EOF'
[debug]
loglevel = 0
tls = 0
nl = 0
[authenticate]
keyrings =
EOF
# Run tlshd
docker run -d --name tlshd \
--privileged \
--network host \
-v /etc/tlshd:/etc/tlshd:ro \
dhi.io/ktls-utils:<tag>
| Feature | Standard Linux Package | Docker Hardened ktls-utils |
|---|---|---|
| Security | Standard system packages | Minimal, hardened base with security patches |
| Shell access | Full shell available | No shell in runtime variants |
| Package manager | apt/yum available | No package manager in runtime variants |
| User | Runs as root via systemd | Runs as nonroot user |
| Attack surface | Larger due to system utilities | Minimal, only essential components |
| Debugging | Traditional shell debugging | Use Docker Debug or Image Mount for troubleshooting |
| Configuration | /etc/tlshd/config | Same configuration file location |
Docker Hardened Images prioritize security through minimalism:
The hardened images intended for runtime don't contain a shell nor any tools for debugging. Common debugging methods for applications built with Docker Hardened Images include:
docker logsFor example, you can use Docker Debug:
docker debug tlshd
or mount debugging tools with the Image Mount feature:
docker run --rm -it --pid container:tlshd \
--mount=type=image,source=dhi.io/busybox:1,destination=/dbg,ro \
dhi.io/ktls-utils:<tag> /dbg/bin/sh
Docker Hardened Images come in different variants depending on their intended use.
Runtime variants are designed to run your application in production. These images are intended to be used either
directly or as the FROM image in the final stage of a multi-stage build. These images typically:
Build-time variants typically include dev in the variant name and are intended for use in the first stage of a
multi-stage Dockerfile. These images typically:
FIPS variants include fips in the variant name and tag. They come in both runtime and build-time variants. These
variants use cryptographic modules that have been validated under FIPS 140, a U.S. government standard for secure
cryptographic operations. Docker Hardened ktls-utils images include FIPS-compliant variants for environments requiring
Federal Information Processing Standards compliance.
To migrate your tlshd deployment to a Docker Hardened Image, you must update your deployment configuration. At minimum, you must update the container image reference to a Docker Hardened Image. This and a few other common changes are listed in the following table of migration notes:
| Item | Migration note |
|---|---|
| Base image | Replace your container images with a Docker Hardened Image. |
| Package management | Non-dev images, intended for runtime, don't contain package managers. Use package managers only in images with a dev tag. |
| Nonroot user | By default, non-dev images, intended for runtime, run as a nonroot user. However, tlshd requires privileged access to kernel netlink sockets, so you must run with --privileged flag. |
| Configuration | Mount your configuration directory to /etc/tlshd. The configuration file format is identical to the standard ktls-utils package. |
| TLS certificates | Docker Hardened Images contain standard TLS certificates by default. Mount your own certificates and configure them in /etc/tlshd/config. |
| Network mode | tlshd typically requires --network host to access kernel sockets directly. |
| Entry point | Docker Hardened ktls-utils maintains the same tlshd command-line options as the standard package. |
| No shell | By default, non-dev images, intended for runtime, don't contain a shell. Use dev images in build stages to run shell commands and then copy artifacts to the runtime stage. |
The following steps outline the general migration process.
Prepare your configuration.
Ensure you have a valid tlshd configuration file at /etc/tlshd/config on your host system. Review the configuration
file reference section above for available options.
Prepare certificates (if using x.509 authentication).
Place your certificates and private keys in a directory that you'll mount into the container. Update your configuration file to reference the paths where these files will be mounted.
Update your container deployment.
Replace your existing tlshd container with the Docker Hardened Image:
docker run -d --name tlshd \
--privileged \
--network host \
-v /etc/tlshd:/etc/tlshd:ro \
dhi.io/ktls-utils:<tag>
Verify operation.
Check the container logs to ensure tlshd started successfully:
docker logs tlshd
You should see log messages indicating that tlshd is listening for netlink messages from the kernel.
The following are common issues that you may encounter during migration.
The hardened images intended for runtime don't contain a shell nor any tools for debugging. The recommended method for debugging applications built with Docker Hardened Images is to use Docker Debug to attach to these containers. Docker Debug provides a shell, common debugging tools, and lets you install other tools in an ephemeral, writable layer that only exists during the debugging session.
For tlshd-specific debugging:
# View logs
docker logs tlshd
# Run with debug output to stderr
docker run -d --name tlshd \
--privileged \
--network host \
-v /etc/tlshd:/etc/tlshd:ro \
dhi.io/ktls-utils:<tag> \
tlshd --stderr
By default, image variants intended for runtime run as the nonroot user. However, tlshd requires privileged access to
kernel netlink sockets and must run with the --privileged flag to function correctly.
tlshd will exit immediately if /etc/tlshd/config does not exist or is malformed. Ensure your configuration file:
/etc/tlshd/config)tlshd requires Linux kernel 6.5 or later with the following CONFIG options enabled:
CONFIG_TLSCONFIG_KEYSCONFIG_KEYS_REQUEST_CACHEVerify your kernel supports net/handshake:
# Check kernel version
uname -r
# Check if /proc/net/handshake exists
ls /proc/net/handshake 2>/dev/null || echo "Kernel handshake support not available"
If tlshd cannot access certificates or keyrings:
/etc/tlshd/config match mounted locationsBy default, image variants intended for runtime don't contain a shell. Use dev images in build stages to run shell
commands and then copy any necessary artifacts into the runtime stage. In addition, use Docker Debug to debug containers
with no shell.
Docker Hardened ktls-utils maintains the same entry point and command-line options as the standard ktls-utils package.
Use docker inspect to inspect entry points for Docker Hardened Images if necessary.