mirror of https://github.com/lukechilds/node.git
Browse Source
`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 <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>canary-base
XadillaX
7 years ago
committed by
Ruben Bridgewater
6 changed files with 60 additions and 29 deletions
@ -0,0 +1,28 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
// Example:
|
||||
|
// C=US\nST=CA\nL=SF\nO=Joyent\nOU=Node.js\nCN=ca1\nemailAddress=ry@clouds.org
|
||||
|
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; |
||||
|
} |
||||
|
|
||||
|
module.exports = { |
||||
|
parseCertString |
||||
|
}; |
Loading…
Reference in new issue