-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
Description
CA certs may be many in number, in which case they can be parsed and served as an array of certs, as noted in this article:
http://nodejs.md/blog/https-server-with-multiple-domains-on-same-port-and-instance/
This is the relevant code:
function sslCAdecode(source) {
var ca = [];
if (!source || typeof(source) !== "string")
return ca;
ca = source.split(/-----END CERTIFICATE-----[\s\n]+-----BEGIN CERTIFICATE-----/).map(function (v, k, arr) {
if (k) {
v = '-----BEGIN CERTIFICATE-----' + v;
}
if (k !== arr.length - 1) {
v = v + '-----END CERTIFICATE-----';
}
v = v.replace(/^\n+/,'').replace(/\n+$/,'');
return v;
});
return ca;
};
Use:
creds.ca = sslCAdecode( fs.readFileSync( site.credentials.ca, 'utf8') );