-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tls: fix empty issuer/subject/infoAccess parsing
Also issuerCertificate but that did not fit on the status line. Fixes: #11771 PR-URL: #14473 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
- Loading branch information
1 parent
eb7faf6
commit e90af29
Showing
2 changed files
with
59 additions
and
4 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,55 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const { strictEqual, deepStrictEqual } = require('assert'); | ||
const { translatePeerCertificate } = require('_tls_common'); | ||
|
||
const certString = 'A=1\nB=2\nC=3'; | ||
const certObject = { A: '1', B: '2', C: '3' }; | ||
|
||
strictEqual(translatePeerCertificate(null), null); | ||
strictEqual(translatePeerCertificate(undefined), null); | ||
|
||
strictEqual(translatePeerCertificate(0), null); | ||
strictEqual(translatePeerCertificate(1), 1); | ||
|
||
deepStrictEqual(translatePeerCertificate({}), {}); | ||
|
||
deepStrictEqual(translatePeerCertificate({ issuer: '' }), | ||
{ issuer: {} }); | ||
deepStrictEqual(translatePeerCertificate({ issuer: null }), | ||
{ issuer: null }); | ||
deepStrictEqual(translatePeerCertificate({ issuer: certString }), | ||
{ issuer: certObject }); | ||
|
||
deepStrictEqual(translatePeerCertificate({ subject: '' }), | ||
{ subject: {} }); | ||
deepStrictEqual(translatePeerCertificate({ subject: null }), | ||
{ subject: null }); | ||
deepStrictEqual(translatePeerCertificate({ subject: certString }), | ||
{ subject: certObject }); | ||
|
||
deepStrictEqual(translatePeerCertificate({ issuerCertificate: '' }), | ||
{ issuerCertificate: null }); | ||
deepStrictEqual(translatePeerCertificate({ issuerCertificate: null }), | ||
{ issuerCertificate: null }); | ||
deepStrictEqual( | ||
translatePeerCertificate({ issuerCertificate: { subject: certString } }), | ||
{ issuerCertificate: { subject: certObject } }); | ||
|
||
{ | ||
const cert = {}; | ||
cert.issuerCertificate = cert; | ||
deepStrictEqual(translatePeerCertificate(cert), { issuerCertificate: cert }); | ||
} | ||
|
||
deepStrictEqual(translatePeerCertificate({ infoAccess: '' }), | ||
{ infoAccess: {} }); | ||
deepStrictEqual(translatePeerCertificate({ infoAccess: null }), | ||
{ infoAccess: null }); | ||
deepStrictEqual( | ||
translatePeerCertificate({ infoAccess: 'OCSP - URI:file:///etc/passwd' }), | ||
{ infoAccess: { 'OCSP - URI': ['file:///etc/passwd'] } }); |