From d61d561b5a078dd419dcc462b60a987ded3864c7 Mon Sep 17 00:00:00 2001 From: XadillaX Date: Thu, 13 Jul 2017 00:26:58 +0800 Subject: [PATCH 1/2] doc: add tls.parseCertString() Refs: https://github.com/nodejs/node/issues/14193 --- doc/api/tls.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/doc/api/tls.md b/doc/api/tls.md index 80cd2e87263566..7c46f114565091 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -1149,6 +1149,37 @@ For example: console.log(tls.getCiphers()); // ['AES128-SHA', 'AES256-SHA', ...] ``` +## tls.parseCertString(str) + + +* `str` {string} A Cert string that joins each key-value pair with `'\n'`. + +Returns the parsed object. eg. + +```js +tls.parseCertString(`C=US +ST=CA +L=SF +O=Joyent +OU=Node.js +CN=ca1 +emailAddress=ry@clouds.org`); +``` + +This will return + +```js +{ C: 'US', + ST: 'CA', + L: 'SF', + O: 'Joyent', + OU: 'Node.js', + CN: 'ca1', + emailAddress: 'ry@clouds.org' } +``` + ## tls.DEFAULT_ECDH_CURVE -* `str` {string} A Cert string that joins each key-value pair with `'\n'`. +* `str` {string} A Cert in [`ini`][] format. -Returns the parsed object. eg. +Returns the parsed object. + +For example: ```js tls.parseCertString(`C=US @@ -1168,7 +1171,7 @@ CN=ca1 emailAddress=ry@clouds.org`); ``` -This will return +This will return — ```js { C: 'US', @@ -1334,3 +1337,4 @@ where `secure_socket` has the same API as `pair.cleartext`. [specific attacks affecting larger AES key sizes]: https://www.schneier.com/blog/archives/2009/07/another_new_aes.html [tls.Server]: #tls_class_tls_server [`dns.lookup()`]: dns.html#dns_dns_lookup_hostname_options_callback +[`ini`]: https://en.wikipedia.org/wiki/INI_file