Setting Up SSL for Angular-Cli Project
1. go to the package.json and locate below line
"start": "ng serve",change it to look like this
"start": "ng serve --ssl true --ssl-key ssl/server.key --ssl-cert ssl/server.crt",
2. now we have to generate certificate filesopenssl genrsa -des3 -passout pass:x -out server.pass.key 2048 ... $ openssl rsa -passin pass:x -in server.pass.key -out server.key writing RSA key $ rm server.pass.key $ openssl req -new -key server.key -out server.csr Country Name (2 letter code) [AU]:US State or Province Name (full name) [Some-State]: Colombo ... A challenge password []: ...3. now we generate ssl certificate
openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt4. we get three files ‘server.key’ ‘server.crt’ (your certificate) ‘server.csr’
5. Ok, now copy the ‘server.crt’ , ‘server.key’ to a folder called ‘ssl’ (you can use any name) which is in the root of the project
6. Done!!.. now run the project using ‘npm start’ command
further investigations can be done by visiting this file /node_modules/angular-cli/tasks/serve-webpack.js