0
0

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 3 years have passed since last update.

Windows 上、mkcert + SpringBoot localhost で https

Last updated at Posted at 2021-06-11

基本の流れ
https://www.jianshu.com/p/0a0e592a8767
https://qiita.com/rkunihiro/items/530b5dc685bd3bff2082

でも、全部 Linux / MacOS + nginx の場合
Windows + Java(SpringBoot) の場合は、探してもなかなか出てこない。。。。

手順は以下通り:

まず、https://github.com/FiloSottile/mkcert/releases からWindows 版をダウンロード。(2021/06/11 現在は 1.4.3 版)
https://github.com/FiloSottile/mkcert/releases/download/v1.4.3/mkcert-v1.4.3-windows-amd64.exe

コマンドプロンプトで以下実行
1.java_home を設定。mkcert は java_home に CA を登録してくれるから。実際 SpringBoot を使用する jvm のパスを指定。

set java_home=D:\pleiades\jre

2.CA を登録。(1回のみ)ログにも出るが、システムとJava両方登録してくれる!Java は java_home の環境変数に依存する。

mkcert-v1.4.3-windows-amd64.exe -install
The local CA is already installed in the system trust store! 👍
The local CA is already installed in Java's trust store! 👍

3.証明書を作成。ドメインをスペースで分ける。Java(SpringBoot)の場合、-pkcs12 が必須!

mkcert-v1.4.3-windows-amd64.exe -pkcs12 192.168.0.19 example.com localhost 127.0.0.1 ::1
Created a new certificate valid for the following names 📜
 - "192.168.0.19"
 - "example.com"
 - "localhost"
 - "127.0.0.1"
 - "::1"

The PKCS#12 bundle is at "./192.168.0.19+4.p12" ✅

The legacy PKCS#12 encryption password is the often hardcoded default "changeit" ℹ️

It will expire on 11 September 2023 🗓

4.できた 192.168.0.19+4.p12 ファイルを SpringBoot の src/main/resources フォルダに置く。

5.SpringBoot の https 設定

application.properties
server.port=8443
server.ssl.key-store=classpath:192.168.0.19+4.p12
server.ssl.key-store-type=PKCS12
server.ssl.key-store-password=changeit

6.以下どれでアクセスしても、問題なく表示するはず。
https://192.168.0.19:8443
https://127.0.0.1:8443
https://localhost:8443

以下参考
https://docs.oracle.com/cd/E19906-01/820-4916/geygn/index.html
https://support.code42.com/Administrator/6/Configuring/Install_a_CA-signed_SSL_certificate_for_HTTPS_console_access
https://connect2id.com/blog/importing-ca-root-cert-into-jvm-trust-store

以上。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?