9
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Angular-cli ng serveでhttps

Posted at

適当な場所に

$ openssl genrsa -des3 -passout pass:pass_hoge -out server_pass.key 2048
$ openssl rsa -passin pass:pass_hoge -in server_pass.key -out server.key
$ openssl req -new -key server.key -out server.csr

Country Name (2 letter code) [AU]:(国名)
State or Province Name (full name) [Some-State]:(都道府県)
Locality Name (eg, city) []:(市町村)
Organization Name (eg, company) [Internet Widgits Pty Ltd]:(組織名)
Organizational Unit Name (eg, section) []:(部署名)
Common Name (e.g. server FQDN or YOUR name) []:(サーバ名:FQDN)
Email Address []:(メールアドレス)
Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

$ openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt

乱数ファイルを利用する場合

$ openssl genrsa -des3 -passout pass:pass_hoge -out server.pass.key 2048

$ openssl dgst -md5 /var/log/system.log > rand.dat
$ openssl genrsa -des3 -passout pass:pass_hoge -rand rand.dat -out server_pass.key 2048

パスフレーズなしでKey作成

$ openssl genrsa -des3 -passout pass:pass_hoge -out server.pass.key 2048

$ openssl genrsa -rand rand.dat 2048 > server.key

ng serve

ng serve --ssl true --ssl-key "server.keyまでのパス" --ssl-cert "server.crtまでのパス"

これでhttpsでアクセスできるはず。

補足

package.json"start": "ng serve""start": "ng serve --ssl true --ssl-key server.keyまでのパス --ssl-cert server.crtまでのパス"
とかにすると npm startの時にhttpsで立ち上がってくれる。
もしくは

  "scripts": {
    "start": "ng serve",
    "hoge": "ng serve --ssl true --ssl-key server.keyまでのパス --ssl-cert server.crtまでのパス",
  },

こんな感じで好きな名前で登録して
$ npm run hoge
でも立ち上がってくれる。

9
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?