Verified Commit 5c6fc0be authored by Aral Balkan's avatar Aral Balkan
Browse files

Progress towards globally-trusted certificates

parent 035d05e6
...@@ -20,6 +20,7 @@ class HttpsServer { ...@@ -20,6 +20,7 @@ class HttpsServer {
// Create and return a TLS server with a locally-trusted certificate. // Create and return a TLS server with a locally-trusted certificate.
createTLSServerWithLocallyTrustedCertificate (options = {}, requestListener = undefined) { createTLSServerWithLocallyTrustedCertificate (options = {}, requestListener = undefined) {
console.log('[https-server] Using local certificates.')
const defaultOptions = { const defaultOptions = {
key: fs.readFileSync(path.join(nodecertDirectory, 'localhost-key.pem')), key: fs.readFileSync(path.join(nodecertDirectory, 'localhost-key.pem')),
cert: fs.readFileSync(path.join(nodecertDirectory, 'localhost.pem')) cert: fs.readFileSync(path.join(nodecertDirectory, 'localhost.pem'))
...@@ -32,9 +33,11 @@ class HttpsServer { ...@@ -32,9 +33,11 @@ class HttpsServer {
// Create and return a TLS server with a globally-trusted certificate. // Create and return a TLS server with a globally-trusted certificate.
createTLSServerWithGloballyTrustedCertificate () { createTLSServerWithGloballyTrustedCertificate () {
console.log('[https-server] Using global certificates. TODO')
// TODO // TODO
} }
// Returns an https server instance – the same as you’d get with // Returns an https server instance – the same as you’d get with
// require('https').createServer – configured with your nodecert certificates. // require('https').createServer – configured with your nodecert certificates.
// If you do pass a key and cert, they will be overwritten. // If you do pass a key and cert, they will be overwritten.
...@@ -42,8 +45,13 @@ class HttpsServer { ...@@ -42,8 +45,13 @@ class HttpsServer {
// TODO: Create local certificate authority and certificates if on development // TODO: Create local certificate authority and certificates if on development
// ===== or use Greenlock on production to ensure that we have Let’s Encrypt // ===== or use Greenlock on production to ensure that we have Let’s Encrypt
// certificates set up. // certificates set up.
if (options.certificateType === 'global') {
return this.createTLSServerWithGloballyTrustedCertificate (options, requestListener)
} else {
// Default to using local certificates.
return this.createTLSServerWithLocallyTrustedCertificate(options, requestListener) return this.createTLSServerWithLocallyTrustedCertificate(options, requestListener)
} }
}
// Starts a static server serving the contents of the passed path at the passed port // Starts a static server serving the contents of the passed path at the passed port
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment