-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crypto: fix assertion caused by unsupported ext
`X509V3_EXT_print` can return value different from `1` if the X509 extension does not support printing to a buffer. Instead of failing with an unrecoverable assertion - replace the relevant value in the hashmap with a JS null value. Fixes: https://hackerone.com/reports/746733 PR-URL: nodejs-private/node-private#175 Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Shelley Vohr <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
- Loading branch information
1 parent
25b6897
commit 1156a9e
Showing
2 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
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,79 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
// NOTE: This certificate is hand-generated, hence it is not located in | ||
// `test/fixtures/keys` to avoid confusion. | ||
// | ||
// The key property of this cert is that subjectAltName contains a string with | ||
// a type `23` which cannot be encoded into string by `X509V3_EXT_print`. | ||
const pem = ` | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEowIBAAKCAQEAzrmfPz5M3wTq2/CwMeSQr/N+R1FCJ+O5n+SMleKvBqaK63eJ | ||
kL4BnySMc+ZLKCt4UQSsPFIBK63QFq8n6/vjuTDMJiBTsvzytw8zJt1Zr2HA71N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u2Qv4CrAO2IPV6JER9Ni | ||
wl3ktzNjOMAUQG6BCRSqRQIDAQABoxswGTAXBgNVHREEEDAOlwwqLmxvY2FsLmhv | ||
c3QwDQYJKoZIhvcNAQENBQADggEBAH5ThRLDLwOGuhKsifyiq7k8gbx1FqRegO7H | ||
SIiIYYB35v5Pk0ZPN8QBJwNQzJEjUMjCpHXNdBxknBXRaA8vkbnryMfJm37gPTwA | ||
m6r0uEG78WgcEAe8bgf9iKtQGP/iydKXpSSpDgKoHbswIxD5qtzT+o6VNnkRTSfK | ||
/OGwakluFSoJ/Q9rLpR8lKjA01BhetXMmHbETiY8LSkxOymMldXSzUTD1WdrVn8U | ||
L3dobxT//R/0GraKXG02mf3gZNlb0MMTvW0pVwVy39YmcPEGh8L0hWh1rpAA/VXC | ||
f79uOowv3lLTzQ9na5EThA0tp8d837hdYrrIHh5cfTqBDxG0Tu8= | ||
-----END CERTIFICATE----- | ||
`; | ||
|
||
const tls = require('tls'); | ||
|
||
const options = { | ||
key: pem, | ||
cert: pem, | ||
}; | ||
|
||
const server = tls.createServer(options, (socket) => { | ||
socket.end(); | ||
}); | ||
server.listen(0, common.mustCall(function() { | ||
const client = tls.connect({ | ||
port: this.address().port, | ||
rejectUnauthorized: false | ||
}, common.mustCall(() => { | ||
// This should not crash process: | ||
client.getPeerCertificate(); | ||
|
||
server.close(); | ||
client.end(); | ||
})); | ||
})); |