PKI.js is a pure JavaScript library implementing the formats that are used in PKI applications (signing, encryption, certificate requests, OCSP and TSP requests/responses). It is built on WebCrypto (Web Cryptography API) and requires no plug-ins.
Error: Please call 'setEngine' before call to 'getEngine'
I didn’t call setEngine() because I pass the crypto engine to each function myself. I instantiated the engine like this:
import { webcrypto } from 'crypto';
const crypto = new CryptoEngine({ name: 'node-webcrypto', crypto: webcrypto as Crypto });
The stack trace told me the error originated in AuthenticatedSafe.makeInternalValues(), so I looked there if maybe the crypto param wasn’t passed down, and I think I found the culprit here:
While developing for nodejs, I got an:
I didn’t call
setEngine()
because I pass the crypto engine to each function myself. I instantiated the engine like this:The stack trace told me the error originated in
AuthenticatedSafe.makeInternalValues()
, so I looked there if maybe thecrypto
param wasn’t passed down, and I think I found the culprit here:https://github.com/PeculiarVentures/PKI.js/blob/469c403d102ee5149e8eb9ad19754c9696ed7c55/src/AuthenticatedSafe.ts#L304
My node version:
v18.14.2