0

I am trying to use jsrsasign library to sign a file. https://kjur.github.io/jsrsasign

How I can proceed to use the key from an imported browser certificate? (local browser certificate generated and imported)

Is it possible to export the key via javascript from local certificate to use in the method below? (to the keyFromLocalCertificate)

var rsa = new RSAKey();

rsa.readPrivateKeyFromPEMString(keyFromLocalCertificate);

Thanks.

Ralf Stein
  • 209
  • 1
  • 12

1 Answers1

0

In general it is not possible to access to the keystore used by browsers due to security restrictions, even with a plugin.

See details and alternatives here: https://stackoverflow.com/a/41101495/6371459

Only if you have generated previously the private key with javascript, or you have access to the key raw data, for example with a p12 file, then you could use a javascript library to do the digital signature.

Note that encryption is done with public key, not the private ( used for digital signatures). In this case the public key can be shared with an alternative mechanism and used to encrypt

Community
  • 1
  • 1
pedrofb
  • 37,271
  • 5
  • 94
  • 142
  • Thanks for the answer. I mean certificate installed into a local browser keystore. I only need to encrypt a string with javascript using a local browser certificate. Is that possible? – Ralf Stein Jan 26 '17 at 10:41
  • I don't have the key raw data. The certificate was already imported into a browser. – Ralf Stein Jan 26 '17 at 10:51
  • Not possible with javascript, even with a plugin due to browser security restrictions. See Http://stackoverflow.com/a/41101495/6371459 and http://stackoverflow.com/questions/38605661/javascript-key-certificate-from-usb-token/38607119#38607119 – pedrofb Jan 26 '17 at 12:57