Sharing Top Content from the Angular-sphere.

Running Angular CLI over HTTPS with a Trusted Certificate

Running Angular CLI over HTTPS with a Trusted Certificate

☞ 

#angularCLI

  • // enable or disable SSL – –ssl boolean: defaults to false// path to root certificate – –ssl-cert 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…
  • If you don’t experience the second problem and you can live with the fact you have an untrusted certificate, you can just stop right here and keep on developing your awesome application.
  • jsonCopy the private key and root certificate from step 1 into the ssl folder.
  • Make sure the file names are like this: – server.key (private key) – server.crt (root certificate)Before we run our application, make sure you have restarted your browser and updated the start script in package.json.

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.

Running Angular CLI over HTTPS with a Trusted Certificate

Comments are closed, but trackbacks and pingbacks are open.