Skip to content

Commit

Permalink
tests: added test checking if certificate before target node is expired
Browse files Browse the repository at this point in the history
  • Loading branch information
tegefaulkes committed Aug 16, 2024
1 parent 09ecd40 commit df02cca
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/nodes/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,21 @@ describe('nodes/utils', () => {
if (result.result === 'fail') fail();
expect(Buffer.compare(result.nodeId, nodeIdIntermediate)).toBe(0);
});
test('fails with expired intermediate before valid target', async () => {
cert = await testTlsUtils.createTLSConfigWithChain([
[keyPairRoot, 0],
[keyPairIntermediate, undefined],
[keyPairLeaf, 0],
[keyPairLeaf, undefined],
]);
const result = await nodesUtils.verifyServerCertificateChain(
[nodeIdIntermediate],
cert.certChainPem.map((v) => wsUtils.pemToDER(v)),
);
expect(result.result).toBe('fail');
if (result.result !== 'fail') utils.never();
expect(result.value).toBe(CryptoError.CertificateExpired);
});
});
describe('server verifyClientCertificateChain', () => {
test('verify with multiple certs', async () => {
Expand Down

0 comments on commit df02cca

Please sign in to comment.