Skip to content

Commit f1c2f26

Browse files
sam-githubMylesBorins
authored andcommitted
doc,test: tls .ca option supports multi-PEM files
Backport-PR-URL: #12468 PR-URL: #10389 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent a1cb699 commit f1c2f26

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

doc/api/tls.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -906,10 +906,21 @@ added: v0.11.13
906906
the same order as their private keys in `key`. If the intermediate
907907
certificates are not provided, the peer will not be able to validate the
908908
certificate, and the handshake will fail.
909-
* `ca`{string|string[]|Buffer|Buffer[]} Optional CA certificates to trust.
910-
Default is the well-known CAs from Mozilla. When connecting to peers that
911-
use certificates issued privately, or self-signed, the private root CA or
912-
self-signed certificate must be provided to verify the peer.
909+
* `ca` {string|string[]|Buffer|Buffer[]} Optionally override the trusted CA
910+
certificates. Default is to trust the well-known CAs curated by Mozilla.
911+
Mozilla's CAs are completely replaced when CAs are explicitly specified
912+
using this option. The value can be a string or Buffer, or an Array of
913+
strings and/or Buffers. Any string or Buffer can contain multiple PEM CAs
914+
concatenated together. The peer's certificate must be chainable to a CA
915+
trusted by the server for the connection to be authenticated. When using
916+
certificates that are not chainable to a well-known CA, the certificate's CA
917+
must be explicitly specified as a trusted or the connection will fail to
918+
authenticate.
919+
If the peer uses a certificate that doesn't match or chain to one of the
920+
default CAs, use the `ca` option to provide a CA certificate that the peer's
921+
certificate can match or chain to.
922+
For self-signed certificates, the certificate is its own CA, and must be
923+
provided.
913924
* `crl` {string|string[]|Buffer|Buffer[]} Optional PEM formatted
914925
CRLs (Certificate Revocation Lists).
915926
* `ciphers` {string} Optional cipher suite specification, replacing the

test/parallel/test-tls-ca-concat.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
// Check ca option can contain concatenated certs by prepending an unrelated
5+
// non-CA cert and showing that agent6's CA root is still found.
6+
7+
const join = require('path').join;
8+
const {
9+
assert, connect, keys
10+
} = require(join(common.fixturesDir, 'tls-connect'))();
11+
12+
connect({
13+
client: {
14+
checkServerIdentity: (servername, cert) => { },
15+
ca: keys.agent1.cert + '\n' + keys.agent6.ca,
16+
},
17+
server: {
18+
cert: keys.agent6.cert,
19+
key: keys.agent6.key,
20+
},
21+
}, function(err, pair, cleanup) {
22+
assert.ifError(err);
23+
return cleanup();
24+
});

0 commit comments

Comments
 (0)