angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng serve not working when setting up local SSL

Open 0x3ch0 opened this issue 4 years ago β€’ 2 comments

🐞 Bug report

Command (mark with an x)

  • [ ] new
  • [ ] build
  • [x] serve
  • [ ] test
  • [ ] e2e
  • [ ] generate
  • [ ] add
  • [ ] update
  • [ ] lint
  • [ ] extract-i18n
  • [ ] run
  • [ ] config
  • [ ] help
  • [ ] version
  • [ ] doc

Description

I am trying to configure my local SSL for my Angular app inside the WSL2 Ubuntu 20.04 environment and what I end up doing is to create a key and cert file using openssl. Everything works fine when I use ng serve --ssl true --ssl-cert CA.crt --ssl-key CA.key but when I configure the angular.json file of my project using the config below:

...
"serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "ssl": true,
            "sslKey": "CA.key",
            "sslCert": "CA.crt"
          }
...

and run it using ng serve I am getting an error of An unhandled exception occurred: error:0909006C:PEM routines:get_name:no start line See "/tmp/ng-tlxl9X/angular-errors.log" for further details.

πŸ”¬ Minimal Reproduction

  1. Generate your own crt and key file using openssl
  2. Register the crt file to the host
  3. Create simple hello world Angular App
  4. Run the app using this command ng serve --ssl true --ssl-cert <path-to-crt-file> --ssl-key <path-to-key-file> the app should work just fine and run in https without any issues.
  5. Configure the app angular.json to use ssl, sslKey, sslCert and run the app again using the command ng serve the app should not run and will throw the error of something similar to this An unhandled exception occurred: error:0909006C:PEM routines:get_name:no start line See "/tmp/ng-tlxl9X/angular-errors.log" for further details.

πŸ”₯ Exception or Error




An unhandled exception occurred: error:0909006C:PEM routines:get_name:no start line
See "/tmp/ng-tlxl9X/angular-errors.log" for further details.

🌍 Your Environment





     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / β–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 13.3.9
Node: 16.16.0
Package Manager: npm 8.15.1
OS: linux x64

Angular: 13.3.11
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1303.9
@angular-devkit/build-angular   13.3.9
@angular-devkit/core            13.3.9
@angular-devkit/schematics      13.3.9
@angular/cli                    13.3.9
@schematics/angular             13.3.9
rxjs                            7.5.6
typescript                      4.6.4

0x3ch0 avatar Jul 30 '22 09:07 0x3ch0

Hello, we reviewed this issue and determined that it doesn't fall into the bug report or feature request category.

Please see: https://stackoverflow.com/questions/63030755/error-error0909006cpem-routinesget-nameno-start-line-node

alan-agius4 avatar Jul 30 '22 11:07 alan-agius4

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.