自己証明書を作成
- プライベートキーを作成
$ openssl genrsa -out private_key 2048
Generating RSA private key, 2048 bit long modulus
...........................................+++
...........................+++
e is 65537 (0x10001)
- パブリックキーを作成
$ openssl req -new -x509 -key private_key -out public_key -days 365
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) []:jp
State or Province Name (full name) []:tokyo
Locality Name (eg, city) []:tokyo
Organization Name (eg, company) []:dmm.com
Organizational Unit Name (eg, section) []:dmm.com
Common Name (eg, fully qualified host name) []:test.dmm.com
Email Address []:test@dmm.com
sslを有効にするため、設定ファイル(app.con)に情報を追加
設定ファイル(./conf/app.conf)に、以下の情報を追加します。
EnableHTTPS = true
HTTPSPort = 443
HTTPSCertFile = "./local_cert/public_key" # 前のステップで作ったパブリックキーのファイルのフルパスを入れる。 自分の場合は「プロジェクトのパス/local_cert/」の直下に置いたのでそのような設定
HTTPSKeyFile = "./local_cert/private_key" # 前のステップで作ったプライベートキーのファイルのフルパスを入れる
beeコマンドで再起動
bee runコマンドで再起動します。以下のような情報が表示されるはずです。
$ bee run
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.10.0
2019/10/03 15:41:27 INFO ▶ 0001 Using 'example-web' as 'appname'
2019/10/03 15:41:27 INFO ▶ 0002 Initializing watcher...
2019/10/03 15:41:34 SUCCESS ▶ 0003 Built Successfully!
2019/10/03 15:41:34 INFO ▶ 0004 Restarting 'magazine-front'...
2019/10/03 15:41:34 SUCCESS ▶ 0005 './magazine-front' is running...
2019/10/03 15:41:34.828 [I] [asm_amd64.s:1337] http server Running on http://:8080
2019/10/03 15:41:34.829 [I] [asm_amd64.s:1337] https server Running on https://:443
2019/10/03 15:42:06.284 [server.go:3010] [HTTP] http: TLS handshake error from 127.0.0.1:56856: remote error: tls: unknown certificate
2019/10/03 15:42:09.062 [server.go:3010] [HTTP] http: TLS handshake error from 127.0.0.1:56881: remote error: tls: unknown certificate
0 件のコメント:
コメントを投稿