Search code examples
browserpki

Generate rsa keypair client-side on the browser


I'm not very expert in this kind of programming, and I know there is several similar questions, but anyone answered exactly that I need.

My team (and I) are developing a Public Key Infrastructure. We are stuck in the key generation (on client side), but we found so few documentation about it.

We know there are these options:

keygen tag --> generates a SPKAC request --> works in Mozilla to internal keystore, token and smartcard

crypto.generateCRMFRequest() --> generates a CRMF Request --> works in Mozilla to internal keystore, token and smartcard

CryptoAPI, CAPI, XEnroll CEnroll --> generates a CSR PKCS#10 (I think so) --> Works in Internet Explorer (we still haven't found code's examples)

Javascript or java Applet (yes I know, both are different) generates in all with sunpkcs11, bouncycastle or iaik API (can't reach any goal)

We found this options. but we don't know how to get the results, how to create to a CSR PKCS#10 request and how to handle it.

please, could you give me an advice about select the strategy, find how to implement and handle results, convert results and so? we are getting crazy!

Example: we know how to use the keygen tag, but we don't know how to set the key to only RSA 2048, and how to handle the SPKAC request to convert in a good CSR signed on SHA256

We tried to develop a Java Applet with iaik API, but the CSR generated had an error.


Solution

  • As Daniel pointed out, SPKAC is not broadly supported (even by CAs), it would be better if viable for your case to use PKCS10 in all browsers.

    Here is an example doing that - https://github.com/PeculiarVentures/csrhelp