From 468110b3276007f445741b41c36beb0ef62d751c Mon Sep 17 00:00:00 2001 From: XadillaX Date: Fri, 8 Sep 2017 15:58:54 +0800 Subject: tls: deprecate parseCertString & move to internal `tls.parseCertString()` exposed by accident. Now move this function to `internal/tls` and mark the original one as deprecated. PR-URL: https://github.com/nodejs/node/pull/14249 Refs: https://github.com/nodejs/node/issues/14193 Reviewed-By: Refael Ackermann Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Sakthipriyan Vairamani --- lib/tls.js | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'lib/tls.js') diff --git a/lib/tls.js b/lib/tls.js index bbf73e6e2ad..91a543cb552 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -23,6 +23,7 @@ const errors = require('internal/errors'); const internalUtil = require('internal/util'); +const internalTLS = require('internal/tls'); internalUtil.assertCrypto(); const net = require('net'); @@ -228,28 +229,11 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) { } }; -// Example: -// C=US\nST=CA\nL=SF\nO=Joyent\nOU=Node.js\nCN=ca1\nemailAddress=ry@clouds.org -exports.parseCertString = function parseCertString(s) { - var out = Object.create(null); - var parts = s.split('\n'); - for (var i = 0, len = parts.length; i < len; i++) { - var sepIndex = parts[i].indexOf('='); - if (sepIndex > 0) { - var key = parts[i].slice(0, sepIndex); - var value = parts[i].slice(sepIndex + 1); - if (key in out) { - if (!Array.isArray(out[key])) { - out[key] = [out[key]]; - } - out[key].push(value); - } else { - out[key] = value; - } - } - } - return out; -}; +exports.parseCertString = internalUtil.deprecate( + internalTLS.parseCertString, + 'tls.parseCertString() is deprecated. ' + + 'Please use querystring.parse() instead.', + 'DEP00XX'); // Public API exports.createSecureContext = require('_tls_common').createSecureContext; -- cgit v1.2.3