Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createSecureContext() {
return tls.createSecureContext({
ca: fs.readFileSync(config.ca),
key: fs.readFileSync(config.key),
cert: fs.readFileSync(config.cert),
ciphers: config.ciphers,
});
}
getSecureContext(servername) {
if (!this.hosts[servername]) {
logger.error(`SNIServer.getSecureContext: Host ${servername} is unknown`);
return null;
}
if (!this.hosts[servername].secureContext) {
this.hosts[servername].secureContext = tls.createSecureContext(this.hosts[servername].certs);
}
return this.hosts[servername].secureContext;
}
TCPServer.prototype._setupTls = function () {
if (!this.options.tls) return
var details = this.options.tls
details.key = details.key || fs.readFileSync(details.keyPath, 'ascii')
details.cert = details.cert || fs.readFileSync(details.certPath, 'ascii')
this.credentials = tls.createSecureContext(details)
}