-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tls: support reading multiple cas from one input
Before this commit you had to pass multiple CA certificates as an array of strings. For convenience you can now pass them as a single string. Fixes: #4096 PR-URL: #4099 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
1 parent
6d4a03d
commit 80f7f65
Showing
2 changed files
with
47 additions
and
29 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,35 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const tls = require('tls'); | ||
const fs = require('fs'); | ||
|
||
const ca1 = | ||
fs.readFileSync(`${common.fixturesDir}/keys/ca1-cert.pem`, `utf8`); | ||
const ca2 = | ||
fs.readFileSync(`${common.fixturesDir}/keys/ca2-cert.pem`, `utf8`); | ||
const cert = | ||
fs.readFileSync(`${common.fixturesDir}/keys/agent3-cert.pem`, `utf8`); | ||
const key = | ||
fs.readFileSync(`${common.fixturesDir}/keys/agent3-key.pem`, `utf8`); | ||
|
||
function test(ca, next) { | ||
const server = tls.createServer({ ca, cert, key }, function(conn) { | ||
this.close(); | ||
conn.end(); | ||
}); | ||
|
||
server.addContext('agent3', { ca, cert, key }); | ||
|
||
const host = common.localhostIPv4; | ||
const port = common.PORT; | ||
server.listen(port, host, function() { | ||
tls.connect({ servername: 'agent3', host, port, ca }); | ||
}); | ||
|
||
server.once('close', next); | ||
} | ||
|
||
const array = [ca1, ca2]; | ||
const string = ca1 + '\n' + ca2; | ||
test(array, () => test(string, () => {})); |