HTTPS 설정하기
1단계: 키 및 자체 서명 인증서 생성
- JDK utility : keytool 이용해서 생성
$ keytool -genkeypair -noprompt \
-alias kitaecode \
-keypass secret \
-keystore src/main/resources/kitaecode-keystore.p12 \
-storeType PKCS12 -storepass secret \
-keyalg RSA -keysize 2048 -validity 365 \
-dname "C=KO, ST=Inchoen, L=Michuhol, O=Inhatc, OU=Cse, CN=localhost" \
-ext "SAN=dns:localhost"
한줄로 작성 :
keytool -genkeypair -alias kitaecode -keypass secret -keystore src/main/resources/kitaecode-keystore.p12 -storeType PKCS12 -storepass secret -keyalg RSA -keysize 2048 -validity 365 -dname "C=KO, ST=Inchoen, L=Michuhol, O=Inhatc, OU=Cse, CN=localhost" -ext "SAN=dns:localhost"
결과 확인 :
keytool -list -v -alias kitaecode -keystore src/main/resources/kitaecode-keystore.p12 -storepass secret
2단계 : security config로 application.properties 업데이트 하기
application.properties
# Server web port
server.port=8443
# Enable HTTPS support (only accept HTTPS requests)
server.ssl.enabled=true
# Alias that identifies the key in the key store
server.ssl.key-alias= kitaecode
# Keystore location
server.ssl.key-store=classpath:kitaecode-keystore.p12
# Keystore password
server.ssl.key-store-password=secret
# Keystore format
server.ssl.key-store-type=PKCS12