p12 file import failure in windows certificate store by forge JavaScript library -
i using forge library create self signed certificate in .p12 format generates private-public key pair using webcryptoapi. when trying import .p12 file in windows certificate store, getting following error :
this link says there might issue private key.
following key generation snippet webcryptoapi
window.crypto.subtle.generatekey({ name: 'rsa-pss', moduluslength: 2048, publicexponent: new uint8array([0x01, 0x00, 0x01]), hash: {name: 'sha-1'} }
and forge code snippet generate p12 follows :
var newpkcs12asn1 = forge.pkcs12.topkcs12asn1( keys.privatekey, [cert], password, {generatelocalkeyid: true, friendlyname: 'test'}, {algorithm: '3des'}); var newpkcs12der = forge.asn1.toder(newpkcs12asn1).getbytes(); var p12b64 = forge.util.encode64(newpkcs12der); var downloadlink = document.createelement("a"); downloadlink.download = "example.p12"; downloadlink.innerhtml = "download file"; downloadlink.setattribute('href', 'data:application/x-pkcs12;base64,' + p12b64); downloadlink.style.display = "none"; downloadlink.click();
note :
- i unable import file in mozilla certificate store also. there might issue p12 file ?
- windows certificate store validating private key password while importing, finish stage fails.
as shown in comments, problem syntax error in pkcs12 encoding params
{generatelocalkeyid: true, friendlyname: 'test',algorithm: '3des'}
it needed set algorithm: '3des'
because forge default encrypts p12 aes-128.
as can read in article rfc7292 standarizes pkcs#12, doesn’t specify need support aes, there enough information use in interoperable way. windows (even windows10)is not able work files produced more secure encryption schemes , ciphers. then, secure algorithm can used triple-des
Comments
Post a Comment