unable to load CA private key
I've set up an OpenVPN server with EasyRSA-3.0.4 on an Ubuntu 18 server and I've signed a dozen of certificates a few weeks ago. Now I can not sign new certificates with the same passphrase that I used before.
Using configuration from ./openssl-easyrsa.cnf
Enter pass phrase for /etc/openvpn/EasyRSA-3.0.4/pki/private/ca.key:
unable to load CA private key
139726911476160:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt:../crypto/evp/evp_enc.c:536:
139726911476160:error:23077074:PKCS12 routines:PKCS12_pbe_crypt:pkcs12 cipherfinal error:../crypto/pkcs12/p12_decr.c:63:
139726911476160:error:2306A075:PKCS12 routines:PKCS12_item_decrypt_d2i:pkcs12 pbe crypt error:../crypto/pkcs12/p12_decr.c:94:
139726911476160:error:0907B00D:PEM routines:PEM_read_bio_PrivateKey:ASN1 lib:../crypto/pem/pem_pkey.c:87:
I know that the passphrase is good as I've saved it and used it multiple times.
That error is generated when you're using the wrong passphrase. If you don't use the correct passphrase, OpenSSL is unable to decrypt the private key, which is indicated in your output above.
Thanks for the reply. Is it possible that an update of openssl would cause this? What should I do now? Do I have to start over with a new setup?
Not likely anything other than you aren't using the right passphrase. If you cannot recall it, you need to start over.
Running this: openssl rsa -in ca.key -text -noout from /etc/openvpn/EasyRSA-3.0.4/pki/private and inserting the pass-phrase works:
root@ovpn-fra-v1:/etc/openvpn/EasyRSA-3.0.4/pki/private# openssl rsa -in ca.key -text -noout Enter pass phrase for ca.key: Private-Key: (2048 bit) modulus:
After I run the openss command from above, I was able to sign my new cert...
root@ovpn-fra-v1:/etc/openvpn/EasyRSA-3.0.4# ./easyrsa sign-req client mirela
subject=
commonName = mirela
Using configuration from ./openssl-easyrsa.cnf
Enter pass phrase for /etc/openvpn/EasyRSA-3.0.4/pki/private/ca.key:
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName :ASN.1 12:'mirela'
Certificate is to be certified until Jan 15 14:58:26 2029 GMT (3650 days)
Certificate created at: /etc/openvpn/EasyRSA-3.0.4/pki/issued/mirela.crt
Is this normal?
Your first command didn't do anything other than inspect the CA private key. When you ran the sign-req this time, you probably just entered the correct passphrase. Nothing about the key itself changed.
That error is generated when you're using the wrong passphrase. If you don't use the correct passphrase, OpenSSL is unable to decrypt the private key, which is indicated in your output above.
Works for me.
Had a similar problem using easy-rsa 3.1.6 (on macOS, but don't think it matters). I was able to sign new requests by using not the CA Key passphrase but the PEM passphrase (both passphrases are asked/created when creating the CA with "easy-rsa build-ca"). So it seems to me that this is a confusion about what passphrase to use when signing requests.