Springboot ssl 인증서 적용

김서현·2022년 6월 14일
0

기존에 tomcat에 ssl 적용시에는 keystore로 했지만, springboot내에서 처리시에는 p12로 반영해야해서 새로 작성함.

  1. 인증서 생성
genrsa -out cert.temp -aes256 2048
  1. Key 생성
rsa -out cert.key -in cert.temp 
  1. csr 생성
req -out cert.csr  -new -key cert.key -subj "/C=kr/ST=Seoul/O=self-signed Cer
openssl.cnf 파일을 읽지 못하는 경우가 있음. 그럴때 사용
ex) req -config ./openssl.cnf -out cert.csr  -new -key cert.key -subj "/C=kr/ST=Seoul/O=self-signed Cer
  1. pem 파일 생성
req -x509 -out cert.pem  -req -signkey cert.key -in cert.csr -days 3650 
openssl.cnf 파일을 읽지 못하는 경우가 있음. 그럴때 사용
ex) req -config ./openssl.cnf -x509 -out cert.pem  -req -signkey cert.key -in cert.csr -days 3650 
  1. crt 파일 생성
req -x509 -out cert.crt -req -signkey cert.key -in cert.csr -days 3650 
openssl.cnf 파일을 읽지 못하는 경우가 있음. 그럴때 사용
ex) req -config ./openssl.cnf -x509 -out cert.crt -req -signkey cert.key -in cert.csr -days 3650 
  1. p12 파일 생성
pkcs12 -out cert.p12 -inkey cert.key -export -in cert.pem
  1. 적용
  • src>main>resources에 6번에서 생성한 p12파일 복사
  • application.properties에 소스 작성
    #SSL
    server.ssl.key-store=classpath:cert.p12
    server.ssl.key-store-type=PKCS12
    server.ssl.key-store-password=password

project > clean 후 재부팅 하면 반영되어 있다!
주의요함은 공인 CA인증서가 아니라 무시하고 사용하면 됨.

0개의 댓글