I'm writing a MEAN app for my university department on my Mac development machine. I started with the boilerplate from mean.io. In the configuration file config/env/all.js
, there is a section for configuring SSL:
https: {
port: false,
// Paths to key and cert as string
ssl: {
key: '',
cert: ''
}
}
I understand that I'm supposed to change port:false
to the port I'm using for SSL, port:443
, and to provide the filepaths to the key and cert.
The steps I've taken:
- create directory
ssl
in the app root - open Keychain Access on mac
- under
Certificates
on the left, I right click on my department's CA-issued (DigiCert) Certificate and click onExport
- Save as
Certificates.p12
inapp_root/ssl
- Click OK when prompted to enter a password to protect exported file to skip doing so
Here's where I'm confused. Based on instructions found here the paths are to the public key and certificate. How do I extract the public key from this Certificates.p12
file, and how do I extract the certificate
from it such that the mean app will correctly load it?
Additional steps I've taken, attempting instructions found here:
public key generation
cd ssl
openssl pkcs12 -in Certificates.p12 -nocerts -nodes | openssl rsa > id_rsa
openssl rsa -in id_rsa -pubout > pubkey.txt
certificate generation
openssl pkcs12 -in Certificates.p12 -clcerts -nokeys -out pubcert.txt
Then I set the following:
https: {
port: 443,
// Paths to key and cert as string
ssl: {
key: rootPath + '/ssl/pubkey.txt',
cert: rootPath + '/ssl/pubcert.txt'
}
}
On trying to run the server, I get the following error:
crypto.js:100
c.context.setKey(options.key);
^
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Object.exports.createCredentials (crypto.js:100:17)
at Server (tls.js:1127:28)
at new Server (https.js:35:14)
at Object.exports.createServer (https.js:54:10)
Any help would be amazing!