v2.6.6: update setSecureContext warning for node < 11.0 only
This commit is contained in:
parent
779ab234ac
commit
7bcd7a2bf7
26
index.js
26
index.js
|
@ -51,7 +51,7 @@ module.exports.create = function (opts) {
|
||||||
);
|
);
|
||||||
httpType = 'http';
|
httpType = 'http';
|
||||||
|
|
||||||
return { server: server, listen: function () { return new Promise(function (resolve, reject) {
|
return { server: server, listen: function () { return new PromiseA(function (resolve, reject) {
|
||||||
args[0] = p;
|
args[0] = p;
|
||||||
args.push(function () {
|
args.push(function () {
|
||||||
if (!greenlock.servername) {
|
if (!greenlock.servername) {
|
||||||
|
@ -68,7 +68,6 @@ module.exports.create = function (opts) {
|
||||||
}
|
}
|
||||||
return greenlock.check({ domains: [ greenlock.servername ] }).then(function (certs) {
|
return greenlock.check({ domains: [ greenlock.servername ] }).then(function (certs) {
|
||||||
if (certs) {
|
if (certs) {
|
||||||
console.info("Using '%s' as default certificate", greenlock.servername);
|
|
||||||
return {
|
return {
|
||||||
key: Buffer.from(certs.privkey, 'ascii')
|
key: Buffer.from(certs.privkey, 'ascii')
|
||||||
, cert: Buffer.from(certs.cert + '\r\n' + certs.chain, 'ascii')
|
, cert: Buffer.from(certs.cert + '\r\n' + certs.chain, 'ascii')
|
||||||
|
@ -135,11 +134,16 @@ module.exports.create = function (opts) {
|
||||||
// ignore the case that check doesn't have all the right args here
|
// ignore the case that check doesn't have all the right args here
|
||||||
// to get the same certs that it just got (eventually the right ones will come in)
|
// to get the same certs that it just got (eventually the right ones will come in)
|
||||||
if (!certs) { return; }
|
if (!certs) { return; }
|
||||||
console.info("Using '%s' as default certificate", domain);
|
if (server.setSecureContext) {
|
||||||
server.setSecureContext({
|
// only available in node v11.0+
|
||||||
key: Buffer.from(certs.privkey, 'ascii')
|
server.setSecureContext({
|
||||||
, cert: Buffer.from(certs.cert + '\r\n' + certs.chain, 'ascii')
|
key: Buffer.from(certs.privkey, 'ascii')
|
||||||
});
|
, cert: Buffer.from(certs.cert + '\r\n' + certs.chain, 'ascii')
|
||||||
|
});
|
||||||
|
console.info("Using '%s' as default certificate", domain);
|
||||||
|
} else {
|
||||||
|
console.info("Setting default certificates dynamically requires node v11.0+. Skipping.");
|
||||||
|
}
|
||||||
server._hasDefaultSecureContext = true;
|
server._hasDefaultSecureContext = true;
|
||||||
}).catch(function (/*e*/) {
|
}).catch(function (/*e*/) {
|
||||||
// this may be that the test.example.com was requested, but it's listed
|
// this may be that the test.example.com was requested, but it's listed
|
||||||
|
@ -210,7 +214,13 @@ module.exports.create = function (opts) {
|
||||||
|
|
||||||
server.then = obj1.listen().then(function (tlsOptions) {
|
server.then = obj1.listen().then(function (tlsOptions) {
|
||||||
if (tlsOptions) {
|
if (tlsOptions) {
|
||||||
server.setSecureContext(tlsOptions);
|
if (server.setSecureContext) {
|
||||||
|
// only available in node v11.0+
|
||||||
|
server.setSecureContext(tlsOptions);
|
||||||
|
console.info("Using '%s' as default certificate", greenlock.servername);
|
||||||
|
} else {
|
||||||
|
console.info("Setting default certificates dynamically requires node v11.0+. Skipping.");
|
||||||
|
}
|
||||||
server._hasDefaultSecureContext = true;
|
server._hasDefaultSecureContext = true;
|
||||||
}
|
}
|
||||||
return obj2.listen().then(function () {
|
return obj2.listen().then(function () {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "greenlock-express",
|
"name": "greenlock-express",
|
||||||
"version": "2.6.4",
|
"version": "2.6.6",
|
||||||
"description": "Free SSL and managed or automatic HTTPS for node.js with Express, Koa, Connect, Hapi, and all other middleware systems.",
|
"description": "Free SSL and managed or automatic HTTPS for node.js with Express, Koa, Connect, Hapi, and all other middleware systems.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"homepage": "https://git.coolaj86.com/coolaj86/greenlock-express.js",
|
"homepage": "https://git.coolaj86.com/coolaj86/greenlock-express.js",
|
||||||
|
|
Loading…
Reference in New Issue