Running an Angular application over a secure connection is pretty straight forward. There are plenty of tutorials how you can enable this. However, you can run into some problems. This blog post…
Running Angular CLI over HTTPS with a Trusted CertificateRunning an Angular application over a secure connection is pretty straight forward. There are plenty of tutorials how you can enable this. However, you can run into some problems.
This blog post covers the basics to run your Angular application over HTTPS and the possible problems it can cause by doing so. At the end a solution is included to solve the most common problems.
Let’s get started!
Enabling SSLThe Angular CLI provides us with three parameters we can pass along with the ng serve command to enable and configure SSL.
// enable or disable SSL
–ssl boolean: defaults to false// path to root certificate
–ssl-cert string: defaults to “ssl/server.crt”// path to private key
–ssl-key string: defaults to “ssl/server.key”Example #1ng serve —-ssl trueSSL is enabledCheck whether there is a certificate and private key in the default ssl folderIf nothing is found, the CLI will generate his own certificate and private keyExample #2ng serve \
–ssl true \
–ssl-cert “/home/john/ssl/example.crt” \
–ssl-key is enabledCheck whether there is a certificate and private key in the given pathIf nothing is found, the CLI will generate his own certificate and private keyProblemsThe browser doesn’t trust our certificate, so we get a warningDisconnect and restart loopCertificate is not trustedThis problem is pretty easy to bypass. We can just ignore the warning and continue to visit our application.