I couldn't manage using SNICallback on createServer
function.
When I try the below codes I get an error as Missing PFX or certificate + pricate key.
How can I solve this issue?
var fs = require('fs'),
tls = require('tls'),
https = require('https');
var certs = {
"safe.myDomain.com": {
key: fs.readFileSync('../SSL/safe/private/key.pem'),
cert: fs.readFileSync('../SSL/safe/certs/cert.pem')
},
"api.myDomain.com": {
key: fs.readFileSync('../SSL/api/private/key.pem'),
cert: fs.readFileSync('../SSL/api/certs/cert.pem')
}
}
var httpsOptions = {
SNICallback: function(hostname, cb) {
var ctx = tls.createSecureContext(certs[hostname])
cb(null, ctx])
}
}
https.createServer(httpsOptions).listen(1443, function() {
console.log('HTTPS server is listening on port 1443')
})