Skip to content

Commit

Permalink
Parsing basicConstraints extension without CA tag but with pathLength…
Browse files Browse the repository at this point in the history
… specified
  • Loading branch information
mchldbrtl authored and erossignon committed Sep 5, 2023
1 parent 5f243ad commit 6f69550
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions packages/node-opcua-crypto/source/crypto_explore_certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,27 @@ extKeyUsage

function readBasicConstraint2_5_29_19(buffer: Buffer, block: BlockInfo): BasicConstraints {
const block_info = readTag(buffer, 0);
const inner_blocks = _readStruct(buffer, block_info);
const cA = inner_blocks.length > 0 ? _readBooleanValue(buffer, inner_blocks[0]) : false;

const inner_blocks = _readStruct(buffer, block_info).slice(0, 2);
let cA = false;
let pathLengthConstraint = 0;
if (inner_blocks.length > 1) {
pathLengthConstraint = _readIntegerValue(buffer, inner_blocks[1]);
let breakControl = 0;

for (const inner_block of inner_blocks) {
switch(inner_block.tag) {
case TagType.BOOLEAN:
cA = _readBooleanValue(buffer, inner_block);
break;
case TagType.INTEGER:
pathLengthConstraint = _readIntegerValue(buffer, inner_block);
breakControl = 1;
break;
}

if (breakControl) {
break;
}
}

return { critical: true, cA, pathLengthConstraint };
}

Expand Down

0 comments on commit 6f69550

Please sign in to comment.