PeculiarVentures / PKI.js

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.
http://pkijs.org
Other
1.3k stars 204 forks source link

fix issue w/ crypto in CertChainValidationEngine #360

Closed bdehamer closed 2 years ago

bdehamer commented 2 years ago

When calling the verify function on the CertificateChainValidationEngine with an explicit crypto parameter you get an error stating "Please call 'setEngine' before call to 'getEngine'"

const cryptoEngine = new pkijs.CryptoEngine({
  name: 'mycrypto',
  crypto: new Crypto(),
});

 const ccve = new pkijs.CertificateChainValidationEngine({
  certs: [rootCert, intCert, signingCert],
  trustedCerts: [rootCert]
});

const result = await ccve.verify({}, cryptoEngine);
console.log(result);
{
  result: false,
  resultCode: -1,
  resultMessage: "Please call 'setEngine' before call to 'getEngine'"
}

The issue seems to be that the verify function doesn't pass the supplied crypto value down to invocation of findIssuer.

coveralls commented 2 years ago

Coverage Status

Coverage remained the same at 74.291% when pulling a6da39674a66f7fe233f16c7ee5de334916f6a0e on bdehamer:cert-chain-engine-fix into 3e3e61439a49a4a8b712bc30641c75b7c8740a8a on PeculiarVentures:master.

microshine commented 2 years ago

@bdehamer Thank you for your update. The new version pkijs@3.0.7 is available