PeculiarVentures / PKI.js

PKI.js is a pure JavaScript library implementing the formats that are used in PKI applications (signing, encryption, certificate requests, OCSP and TSP requests/responses). It is built on WebCrypto (Web Cryptography API) and requires no plug-ins.
http://pkijs.org
Other
1.25k stars 204 forks source link

Convert PEM to CryptoKey #394

Open gabrypulzio opened 5 months ago

gabrypulzio commented 5 months ago

Hi, I followed the example at https://github.com/PeculiarVentures/PKI.js/blob/ace03e1c1f141d0c52da26360012e58ebe77932a/examples/OpenSSLPrivateKeyEncryption/es6.ts#L10 to create an encrypted private key in PEM format.

Now I would like to import the PEM data back to a CrytpoKey. Always in the same example file there's a method: pkijs.RSAPrivateKey.fromBER(decryptedKey) to create a RSAPrivateKey from the decrypted private key but I can't find a way to create a CrytpoKey instead or to import the RSAPrivateKey into a CrytpoKey.