Open phoe opened 6 years ago
Yes, this function works only for PKCS#1 files. You need to convert PKCS#8 to PKCS#1 with openssl:
openssl pkey -in pkcs8.pem -traditional > pkcs1.key
can extract private key from PKCS#8, example:
(let* ((pem-file #P"/var/tmp/KEY/rsa_private_pkcs8.pem")
(pkcs8-der (asn1:decode (base64:base64-string-to-usb8-array
(cdar (pem:parse-file pem-file)))))
(pkcs1-der (asn1:decode (cdr (fourth (car pkcs8-der))))))
(trivia:match pkcs1-der
((asn1:rsa-private-key :private-exponent d :modulus n)
(ironclad:make-private-key :rsa :d d :n n))))
whenever the file contains a private key in form: