How to properly configure gRPC mTLS with pkcs11-provider? #694
Replies: 1 comment 1 reply
-
This is what should happen, please provide some logs to show what else is happening. |
Beta Was this translation helpful? Give feedback.
-
This is what should happen, please provide some logs to show what else is happening. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello All,
I'm working on setting up gRPC mTLS connections with pkcs11-provider and SoftHSM, and I've run into some issues. I'd appreciate any guidance you could provide.
My setup:
openssl.cnf has a minimal pkcs11-provider configuration:
[pkcs11_sect]
module = /usr/lib/ossl-modules/pkcs11.so
pkcs11-module-path = /usr/lib/softhsm/libsofthsm2.so
activate = 1
I've tried two approaches:
First approach: I'm using CA and client certificate chains exported from SoftHSM in PEM format, with the private key provided via a pkcs11-provider URI. I expected OpenSSL to use the default provider for operations that don't require the private key, and only switch to pkcs11-provider when the private key is needed. The initial mTLS connection works, but reconnections fail because OpenSSL caches the pkcs11-provider after the first connection and then uses it for other mTLS operations, not just private key operations.
Second approach: I tried providing all certificates as pkcs11-provider URIs, but that didn't work. It seems PEM_read_bio_X509_AUX (which gRPC uses to read certificates) doesn't use the provider API, also I'm not sure whether pkcs11-provider implements decoder for reading certificates.
Any suggestions would be very helpful. Thank you for your time!
Beta Was this translation helpful? Give feedback.
All reactions