-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix certificate exploration by handle othernames
- Loading branch information
1 parent
88914c5
commit 6813d1d
Showing
8 changed files
with
109 additions
and
10 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
packages/node-opcua-crypto-test/test-fixtures/certs/strange-certificate.pem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIID/jCCAuagAwIBAgIIZJvScHwEdR4wDQYJKoZIhvcNAQELBQAwYDEfMB0GCgmSJomT8ixkARkW | ||
D0VDMkFNQVotNFFKR0RDTTELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB1Vua25vd24xHjAcBgNVBAMT | ||
FU9QQy1Sb3V0ZXItTWlkZGxld2FyZTAeFw0yNDA5MjAxNjU1NDhaFw0zNDA5MjAxNjU1NDhaMGAx | ||
HzAdBgoJkiaJk/IsZAEZFg9FQzJBTUFaLTRRSkdEQ00xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdV | ||
bmtub3duMR4wHAYDVQQDExVPUEMtUm91dGVyLU1pZGRsZXdhcmUwggEiMA0GCSqGSIb3DQEBAQUA | ||
A4IBDwAwggEKAoIBAQCsHj5qkQvHObJhVeaZBqSydJ2QpnI6kW7wC3oGrEu15k0BspYvBPU4mvh4 | ||
fMU4vF3YSCMI85dmo+Urjuz0dEpYYVsSOtaMqyBpiFym50R3QgpeRPYsoohKiif2gopp1sraaLx6 | ||
INybVETagw+ZskBjbVmFR2fwMe55DWL7qDqzpWQQGC5wSxPMOOhTB4adHj6JIw18y1uD4g1dFq7c | ||
ZD0kK+XZ3o5dtBq+uEYZbyOugfUJMH5oAKZlUt9wCDGveBbqpOWoj6sd/0JMZ2t+6Bm5Pevf2jaU | ||
D/Ba9RIckODMrjjD9a3RvddXGTb48ubQUI7iS7+mbqOMl0j/U2u4nJ6JAgMBAAGjgbswgbgwfwYD | ||
VR0RBHgwdocEfwAAAYcQAAAAAAAAAAAAAAAAAAAAAYYkdXJuOkVDMkFNQVotNFFKR0RDTTppbnJh | ||
eTpPUEMtUm91dGVyoCUGCisGAQQBgjcUAgOgFwwVT1BDLVJvdXRlci1NaWRkbGV3YXJlgg9FQzJB | ||
TUFaLTRRSkdEQ00wCQYDVR0TBAIwADALBgNVHQ8EBAMCAvQwHQYDVR0lBBYwFAYIKwYBBQUHAwEG | ||
CCsGAQUFBwMCMA0GCSqGSIb3DQEBCwUAA4IBAQB7An9+Ct9hM8LDz5xWXurBplrtUOeYZwuP8eDB | ||
xuaQkh0yav3W+PqUplR9HYM6jzZFdttIHLwaefNmvteFicbe95nQZDl6kAZ3QhXFn8AKU+6zTbon | ||
5SlWfGLOUUNDPSnwYY5lARytMmrlM9+8Lge5MUCPdMNmma67gqoNGhLAbXfjJcwRURH79XL66lBs | ||
8unuvC1bgZHLMhATRg62EA3gJz21hDzA6NMfZG4xHLOzumXPJcCunz5P7PfBHsTvRB5ZEaZLRpRI | ||
PEkqytds1IBzo/ZbgHuV67WzcKQHTHZtnUYLttpRKHB8kbgrPTUw8249RF0Gg9o5r+cZjr9MXvRt | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
*.js | ||
*.js.map | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { BlockInfo, readTag, _readStruct, TagType } from "./asn1"; | ||
import { hexDump } from "./crypto_utils"; | ||
|
||
function t(tag: number) { | ||
// convert Asn1 tag to string | ||
return TagType[tag]; | ||
} | ||
function bi(blockInfo: BlockInfo, depth: number) { | ||
const indent = " ".repeat(depth); | ||
const hl = blockInfo.position - blockInfo.start; // header length | ||
return `${blockInfo.start.toString().padStart(5, " ")}:d=${depth} hl=${hl.toString().padEnd(3, " ")} l=${blockInfo.length | ||
.toString() | ||
.padStart(6, " ")} ${blockInfo.tag.toString(16).padEnd(2, " ")} ${indent} ${t(blockInfo.tag)}`; | ||
} | ||
|
||
export function exploreAsn1(buffer: Buffer) { | ||
console.log(hexDump(buffer)); | ||
|
||
function dump(offset: number, depth: number) { | ||
const blockInfo = readTag(buffer, offset); | ||
dumpBlock(blockInfo, depth); | ||
|
||
function dumpBlock(blockInfo: BlockInfo, depth: number) { | ||
console.log(bi(blockInfo, depth)); | ||
if (blockInfo.tag === TagType.SEQUENCE || blockInfo.tag === TagType.SET || blockInfo.tag >= TagType.CONTEXT_SPECIFIC0) { | ||
const blocks = _readStruct(buffer, blockInfo); | ||
for (const block of blocks) { | ||
dumpBlock(block, depth +1); | ||
} | ||
} | ||
} | ||
} | ||
dump(0, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters