digitalbazaar / forge

A native implementation of TLS in Javascript and tools to write crypto-based and network-heavy webapps
https://digitalbazaar.com/
Other
5.05k stars 779 forks source link

Missing signers information in PEM to PKCS#7 coversion #368

Open votingsystem opened 8 years ago

votingsystem commented 8 years ago

I've testing forge.pkcs7 and I've seen that the PEM to PKCS7 conversion doesn't add signers information, is there a quick fix for this? Thanks

dlongley commented 8 years ago

Are you calling addSigner and then sign? Can you provide some example code demonstrating the problem?

votingsystem commented 8 years ago

Here https://jsfiddle.net/1my5hxze/14/ you can see a document signed and then converted to PEM. After loading that PEM the signers are missing (more details in the browser console).

When I load that PEM with other tools the signers are there.

dlongley commented 8 years ago

@votingsystem,

You're right. I think the implementation for that was never finished. This function needs to call _signersFromAsn1:

https://github.com/digitalbazaar/forge/blob/master/js/pkcs7.js#L130-L145

And then the authenticated/unauthenticated attributes need to be parsed here:

https://github.com/digitalbazaar/forge/blob/master/js/pkcs7.js#L917-L919

There's not much missing there and PRs are welcome.