40
57

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.

Spring bootでSSL(HTTPS)を有効にする

Last updated at Posted at 2016-02-29

はじめに

以下のURLを和訳しただけです。
https://www.drissamri.be/blog/java/enable-https-in-spring-boot/
簡単でした。

Step1. SSL証明書を取得する

本番の場合はどこか適切なところでお金を払ってSSL証明書を取得してください。
開発版なら以下のようにして作れます。Linuxで作るか、Windowsでもcygwinがあれば作れます。

keytool -genkey -alias tomcat
 -storetype PKCS12 -keyalg RSA -keysize 2048
 -keystore keystore.p12 -validity 3650

Enter keystore password:mypassword
 Re-enter new password:mypassword
 What is your first and last name?
 [Unknown]:
 What is the name of your organizational unit?
 [Unknown]:
 What is the name of your organization?
 [Unknown]:
 What is the name of your City or Locality?
 [Unknown]:
 What is the name of your State or Province?
 [Unknown]:
 What is the two-letter country code for this unit?
 [Unknown]:
 Is CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown correct?
 [no]: yes

Step2. HTTPSを有効化する

設定ファイルに書くだけです。

application.properties
server.port: 8443
server.ssl.key-store: keystore.p12
server.ssl.key-store-password: mypassword
server.ssl.keyStoreType: PKCS12
server.ssl.keyAlias: tomcat

keystore.p12の場所は任意の場所に置けそうです。デフォルトではプロジェクトホームを探します。

あとはhttps://localhost:8443にアクセスしてみてください。

Step3. HTTPからHTTPSへリダイレクトする

試していないので省略

40
57
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
40
57

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?