Fazal Rasel
Fazal Rasel

Reputation: 4526

Cloudflare worker generate smime signature

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,

  1. Is it possible to increase node-forge process by setting any properties?
  2. Is there any other alternative other then node-forge which I can use (expecting some example, I studies pkijs)

Looking for guide line.

Upvotes: 0

Views: 438

Answers (2)

rmhrisk
rmhrisk

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

Kenton Varda
Kenton Varda

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

Related Questions