https://www.runit.cloud/2020/04/https-ssl.html
[HTTPS] 자체 서명 사설 SSL 인증서 만들기
IT 인프라에 관한 모든 것을 다루는 개인 기술 블로그입니다.
www.runit.cloud
인증서 만들기는 위에 잘나와있다.
이중에 필요한것만 정리해보면...
크게 나누면 Server용 인증서와 Root 인증서를 만들면된다.
Server = Private, Root = Public
[Root 인증서만들기]
키생성(key)
openssl ecparam -out rootca.key -name prime256v1 -genkey
rootca.csr 인증 서명 요청 파일 만들기(csr)
openssl req -new -sha256 -key rootca.key -out rootca.csr
----- Country Name (2 letter code) [XX]:KR
State or Province Name (full name) []:Seoul L
ocality Name (eg, city) [Default City]:Seoul
Organization Name (eg, company) [Default Company Ltd]: Google <---- 회사이름
Organizational Unit Name (eg, section) []: Cloud <---- 부서이름
Common Name (eg, your name or your server's hostname) []: IT <--------이름암꺼나...Server랑은 다른거
Email Address []: tech@google.com
Please enter the following 'extra' attributes to be sent with your certificate request
A challenge password []:
An optional company name []:
rootca.crt SSL 인증서 파일 만들기(crt)
openssl x509 -req -sha256 -days 999999 -in rootca.csr -signkey rootca.key -out rootca.crt
[Server 인증서만들기]
키생성(key)
openssl ecparam -out server.key -name prime256v1 -genkey
server.csr 인증 서명 요청 파일 만들기(csr)
openssl req -new -sha256 -key server.key -out server.csr
----- Country Name (2 letter code) [XX]:KR
State or Province Name (full name) []:Seoul L
ocality Name (eg, city) [Default City]:Seoul
Organization Name (eg, company) [Default Company Ltd]: Google <---- 회사이름
Organizational Unit Name (eg, section) []: Cloud <---- 부서이름
Common Name (eg, your name or your server's hostname) []: it.cloud.co.kr <--------URL주소 정확해!
Email Address []: tech@google.com
Please enter the following 'extra' attributes to be sent with your certificate request
A challenge password []:
An optional company name []:
extention.ext 만들기 ( 크롬에서 정상작동을 위해)
extention.ext파일을 만들고 안에내용을 아래와 같이 적어준다.
[alt_names]에 원하는 DNS를 넣어준다.
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
server.crt SSL 인증서 파일 만들기(crt)
openssl x509 -req -sha256 -days 999999 -in server.csr -CA rootca.crt -CAkey rootca.key -CAcreateserial -out server.crt -extfile extention.ext
인증서 정보 확인
openssl x509 -in server.crt -text -noout
[Spring Boot에 적용하기]
CA 인증서를 포함하는 서버 인증서 만들기
cat server.crt rootca.crt > server.pem
Spring Boot용 p12파일 생성
openssl pkcs12 -export -inkey server.key -in server.pem -out key.p12 -name System
비밀번호 입력 : xxx
application.yml 설정추가
server.ssl.enabled: true
server.ssl.key-store: key.p12
server.ssl.key-store-password: xxx # 위에 비밀번호에 넣은것
server.ssl.key-store-type: PKCS12
server.ssl.key-alias: System # 위에 name에 넣은것
[Local에서 접속]
1. rootca.crt 파일로 설치 - 신뢰할수 있는 루트 인증 기관
2. hosts 파일 등록
ip URL (아까등록한 URL)
3. 해당 URL로 접속
'개발자를 벗어나긴 글렀다. > Spring boot' 카테고리의 다른 글
스프링부트 HTTPS 적용 & HTTP HTTPS 동시적용 (0) | 2020.09.17 |
---|---|
springboot 2.1.x에서 2.3.x 버전으로 업그레이드 (0) | 2020.09.10 |
Spring Boot + ES 연계방식 탐구 (0) | 2020.09.09 |
Spring boot + Asp 로 request / response logging (0) | 2019.01.14 |
Spring boot + WebSocket (0) | 2019.01.10 |