Cannot revoke cert if CA key protected by passphrase
zoomequipd opened this issue · 1 comments
zoomequipd commented
Error
When attempted to revoke a certificate that was signed with a CA that is protected by passphrase, the following error is generated
/tmp # /usr/bin/certstrap revoke --CN Alice --CA CertAuth
could not get "CertAuth" private key: unmatched type or headers
Desc and Quick Analysis
It would seem that an error condition within revoke.go - Lines 115-118 is hit.
Lines 115 to 118 in 1eaeef9
I believe this stems from a direct call to depot.GetPrivateKey
without a retry logic for depot.GetEncryptedPrivateKey
I'm not 100% sure, but I think the revoke.go should probably re-use logic similar to the sign.go - Lines 126-138
Lines 126 to 138 in ec28c5a
Step to reproduce
/tmp # /usr/bin/certstrap init --common-name "CertAuth"
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Created out/CertAuth.key (encrypted by passphrase)
Created out/CertAuth.crt
Created out/CertAuth.crl
/tmp # /usr/bin/certstrap request-cert --common-name Alice
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Created out/Alice.key
Created out/Alice.csr
/tmp # /usr/bin/certstrap sign Alice --CA CertAuth
Enter passphrase for CA key (empty for no passphrase):
Created out/Alice.crt from out/Alice.csr signed by out/CertAuth.key
/tmp # /usr/bin/certstrap revoke --CN Alice --CA CertAuth
could not get "CertAuth" private key: unmatched type or headers
isemaya-square commented
We fixed this issue in #165