How to Create Self-signed SSL Certificate in my Angular5 App (localhost)

Let’s make self-signed certificate and set it for angular 6 https://localhost:4200 server.

Move to the project and create a directory

1
2
cd [project_name]
mkdir certs

Generate a self-signed cert

-days 3650 : 10 years expire time
-nodes : skip passphrase

1
openssl req -x509 -newkey rsa:4096 -sha256 -keyout certs/localhost.key.pem -out certs/localhost.cert.pem -days 3650 -nodes -subj '/CN=localhost:4200'

Add package.json

1
2
3
"scripts": {
"start:ssl": "ng serve --aot --ssl --ssl-key './certs/localhost.key.pem' --ssl-cert './certs/localhost.cert.pem'",
},

Run local SSL server

1
npm run start:ssl

Open the browser https://localhost:4200

Useful Links