Created
June 26, 2025 14:06
-
-
Save joostd/0c8fa7a2540f72a5e11a9a19106e1797 to your computer and use it in GitHub Desktop.
Use OpenSSL with YubiHSM2 via pkcs11-provider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:24.04 | |
USER root | |
ENV YUBIHSM_PKCS11_CONF="/opt/yubihsm.conf" | |
WORKDIR /opt | |
COPY <<EOF yubihsm.conf | |
connector=http://host.docker.internal:12345 | |
EOF | |
COPY <<EOF openssl.conf | |
HOME = . | |
openssl_conf = openssl_init | |
[openssl_init] | |
providers = provider_sect | |
[provider_sect] | |
default = default_sect | |
pkcs11 = pkcs11_sect | |
[default_sect] | |
activate = 1 | |
[pkcs11_sect] | |
module = /usr/lib/x86_64-linux-gnu/ossl-modules/pkcs11.so | |
pkcs11-module-path = /usr/lib/x86_64-linux-gnu/pkcs11/yubihsm_pkcs11.so | |
activate = 1 | |
EOF | |
RUN apt update && apt install -y \ | |
curl \ | |
wget \ | |
pkcs11-provider \ | |
libpcsclite1 \ | |
libusb-1.0-0 \ | |
libedit2 | |
RUN wget https://developers.yubico.com/YubiHSM2/Releases/yubihsm2-sdk-2025-06-ubuntu2404-amd64.tar.gz && \ | |
tar xf yubihsm2-sdk-2025-06-ubuntu2404-amd64.tar.gz | |
RUN dpkg -i \ | |
yubihsm2-sdk/libyubihsm-http1_2.7.0_amd64.deb \ | |
yubihsm2-sdk/libyubihsm1_2.7.0_amd64.deb \ | |
yubihsm2-sdk/libykhsmauth1_2.7.0_amd64.deb \ | |
yubihsm2-sdk/yubihsm-shell_2.7.0_amd64.deb \ | |
yubihsm2-sdk/yubihsm-pkcs11_2.7.0_amd64.deb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use yubihsm-shell to generate a key. For instance
Start the connector locally:
Build your Docker image:
Run OpenSSL in a container. For instance: