Reputation: 4526
Generating smime (CMS) signature with node-forge working good on Cloudflare Worker Editor, but When I deploy the code, I'm getting CPU Timeout (Error 1102).
So, I assume, when I call signature.sign({ detached: true });
, it just taking time to generate signature.
I'm using Business: 50ms
.
So,
Looking for guide line.
Upvotes: 0
Views: 438
Reputation: 1856
CloudFlare has added WebCrypto to the workers recently. You really dont want to use JS crypto, Forge is full of it, see Javascript Cryptography Considered Harmful for why.
If what you want is a pure crypto signature you don't even need PKIjs, just use it directly
If you really want S/MIME a look at PKIjs and use WebCrypto. the S/MIME examples.
Upvotes: 0
Reputation: 45326
Unfortunately, cryptographic algorithms implemented in pure JavaScript are likely to run very slowly and exceed the current CPU time limits imposed by Workers.
Instead, try using the WebCrypto API. Workers supports some of WebCrypto, and in particular it supports generating signatures in RSASSA-PKCS1-v1_5
format. Based on a quick Google search it looks like this may be what you need for S/MIME.
Upvotes: 2