-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcertificate.js
More file actions
26 lines (25 loc) · 803 Bytes
/
certificate.js
File metadata and controls
26 lines (25 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var fs = require('fs'),
tls = require('tls');
// Use SNICallback
module.exports = {
SNICallback: function(servername, cb) {
var certificates = {
"domain.com": ["/etc/apache2/ssl/domain_com.key", "/etc/apache2/ssl/domain_com.crt", "/etc/apache2/ssl/geotrust_ssl_intermediate_ca.crt"],
};
if(certificates[servername]){
var ctx = tls.createSecureContext({
key: fs.readFileSync(certificates[servername][0]),
cert: fs.readFileSync(certificates[servername][1]),
ca: [fs.readFileSync(certificates[servername][2])]
});
if(cb){
cb(null, ctx);
}else{
return ctx;
}
}
},
// defauls
key: fs.readFileSync('/etc/apache2/ssl/apache.key', 'utf8'),
cert: fs.readFileSync('/etc/apache2/ssl/apache.crt', 'utf8')
};