Closed nestorsamelo closed 3 years ago
I was able to generate the CSR using tpm2-openssl and the tpm2-tss-engine's private key. You are likely using some older combination of openssl, tpm2-tss and tpm2-openssl. For example, the tpm2-openssl now requires -provider default
to load a certificate from a file.
However, I found another bug that prevents a correct usage of the tpm2-tss library with tpm2-openssl and openssl 3.0. I will fix that first and then come back to you.
@nestorsamelo could you please try your test again, using the master branch of openssl, tpm2-tss and tpm2-openssl? There have been multiple fixes in all of them.
@gotthardp I was not able to verify this using openssl 3.0.0 (released on Sep 7), tpm2-tss (commit ec58f0a43931b18de9c3c5e0cd884892c218041a), and tpm2-openssl (commit d2499aa763da01fcdae37f6c70fcab52f33c2fc4).
# tpm2tss-genkey -a rsa privkey.pem
# openssl req -new -nodes -provider tpm2 -key privkey.pem -out csr_prov.pem -subj '/CN=mydomain.net/'
4060A7A1197F0000:error:020000B3:rsa routines:rsa_ossl_private_encrypt:missing private key:../openssl-3.0.0/crypto/rsa/rsa_ossl.c:329:
4060A7A1197F0000:error:1C880004:Provider routines:rsa_sign:RSA lib:../openssl-3.0.0/providers/implementations/signature/rsa_sig.c:580:
4060A7A1197F0000:error:06880006:asn1 encoding routines:ASN1_item_sign_ctx:EVP lib:../openssl-3.0.0/crypto/asn1/a_sign.c:284:
I must be missing something. Perhaps I need to get tpm2-tools and tpm2-abrmd from master as well? I will try that later.
Thank you.
could you add -provider default
, please?
# tpm2tss-genkey -a rsa privkey.pem
# openssl req -new -nodes -provider tpm2 -provider default -key privkey.pem -out csr_prov.pem -subj '/CN=mydomain.net/'
I got essentially the same:
# tpm2tss-genkey -a rsa privkey.pem
# openssl req -new -nodes -provider tpm2 -provider default -key privkey.pem -out csr_prov.pem -subj '/CN=mydomain.net/'
4080A7770F7F0000:error:020000B3:rsa routines:rsa_ossl_private_encrypt:missing private key:../openssl-3.0.0/crypto/rsa/rsa_ossl.c:329:
4080A7770F7F0000:error:1C880004:Provider routines:rsa_sign:RSA lib:../openssl-3.0.0/providers/implementations/signature/rsa_sig.c:580:
4080A7770F7F0000:error:06880006:asn1 encoding routines:ASN1_item_sign_ctx:EVP lib:../openssl-3.0.0/crypto/asn1/a_sign.c:284:
I haven't tried openssl from master instead of 3.0.0.
There must be something wrong with the way the libraries are built. It's also surprising you are not getting any human-friendly error. Could you please let me know:
1) What gets printed when you do openssl list -providers -provider tpm2 -provider default
2) What ./Configure
arguments you used to build openssl
@gotthardp
Here is the information you requested.
# openssl list -providers -provider tpm2 -provider default
Providers:
default
name: OpenSSL Default Provider
version: 3.0.0
status: active
legacy
name: OpenSSL Legacy Provider
version: 3.0.0
status: active
tpm2
name: TPM 2.0 Provider
version: 1.0.0-rc0
status: active
./Configure disable-devcryptoeng enable-fips enable-acvp-tests no-ssl no-idea no-rc5 no-md2 no-camellia no-mdc2 no-scrypt no-seed no-siphash no-sm2 no-sm3 no-sm4 --prefix=/usr --openssldir=/usr/lib/ssl-3 --libdir=/usr/lib linux-x86_64
@nestorsamelo, I still cannot reproduce this.
There is one more thing that could be different: your openssl configuration. (You have the legacy provider loaded although you didn't load it from the command line. That's weird.)
Please have a look at the openssl.cnf
file in openssl info -configdir
. Did you make some changes to it?
@gotthardp
After I updated tpm2-tools to version 5.2, I was able to generate the CSR as you described.
# tpm2tss-genkey -a rsa privkey.pem
# openssl req -new -nodes -provider tpm2 -provider default -key privkey.pem -out csr_prov.pem -subj '/CN=mydomain.net/'
Thank you very much.
Great, thanks for all the testing!
I was unable to generate a new Certificate Signing Request using the provider with OpenSSL 3.0.0-beta2:
However, the analogous engine-based command works: