Next.js+React web interface for controlling HAProxy clusters (groups of servers), in conjunction with with https://gitgud.io/fatchan/haproxy-protection.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
741 B
24 lines
741 B
'use strict';
|
|
|
|
const https = require('https')
|
|
|
|
const agentOptions = {
|
|
rejectUnauthorized: !process.env.ALLOW_SELF_SIGNED_SSL,
|
|
};
|
|
|
|
if (process.env.PINNED_FP) {
|
|
// console.log('Pinned fingerprint:', process.env.PINNED_FP);
|
|
agentOptions.checkServerIdentity = (host, cert) => {
|
|
//TODO: host verification? e.g. tls.checkServerIdentity(host, cert);
|
|
// console.log('Checking:', cert.fingerprint256);
|
|
if (process.env.PINNED_FP !== cert.fingerprint256) {
|
|
return new Error('Certificate not pinned');
|
|
}
|
|
}
|
|
}
|
|
if (process.env.CUSTOM_CA_PATH) {
|
|
// console.log('Private CA file path:', process.env.CUSTOM_CA_PATH);
|
|
agentOptions.ca = require('fs').readFileSync(process.env.CUSTOM_CA_PATH);
|
|
}
|
|
|
|
module.exports = new https.Agent(agentOptions);
|
|
|