mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Key and certificate as string or buffer
This commit is contained in:
parent
f1e7ec0c6b
commit
7f2627dbc8
7
packages/node_modules/node-red/red.js
vendored
7
packages/node_modules/node-red/red.js
vendored
@ -234,8 +234,13 @@ httpsPromise.then(function(startupHttps) {
|
|||||||
// Get the result of the function, because createServer doesn't accept functions as input
|
// Get the result of the function, because createServer doesn't accept functions as input
|
||||||
Promise.resolve(settings.https()).then(function(refreshedHttps) {
|
Promise.resolve(settings.https()).then(function(refreshedHttps) {
|
||||||
if (refreshedHttps) {
|
if (refreshedHttps) {
|
||||||
|
// The key/cert needs to be updated in the NodeJs http(s) server, when no key/cert is yet available or when the key/cert has changed.
|
||||||
|
// Note that the refreshed key/cert can be supplied as a string or a buffer.
|
||||||
|
var updateKey = (server.key == undefined || (Buffer.isBuffer(server.key) && !server.key.equals(refreshedHttps.key)) || (typeof server.key == "string" && server.key != refreshedHttps.key));
|
||||||
|
var updateCert = (server.cert == undefined || (Buffer.isBuffer(server.cert) && !server.cert.equals(refreshedHttps.cert)) || (typeof server.cert == "string" && server.cert != refreshedHttps.cert));
|
||||||
|
|
||||||
// Only update the credentials in the server when key or cert has changed
|
// Only update the credentials in the server when key or cert has changed
|
||||||
if(!server.key || !server.cert || !server.key.equals(refreshedHttps.key) || !server.cert.equals(refreshedHttps.cert)) {
|
if(updateKey || updateCert) {
|
||||||
server.setSecureContext(refreshedHttps);
|
server.setSecureContext(refreshedHttps);
|
||||||
RED.log.info(RED.log._("server.https.settings-refreshed"));
|
RED.log.info(RED.log._("server.https.settings-refreshed"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user