Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

개발자 되버리기

Zero SSL 인증서 적용 SpringBoot + Vue.Js (SPA) 본문

Linux/Ubuntu

Zero SSL 인증서 적용 SpringBoot + Vue.Js (SPA)

구본익 2022. 1. 1. 15:59

 

최대한 비용 부담을 줄이면서 보안도 신경쓰고.. 개발하고.. 인증하기 위해서 노력을 많이 하는 편...

 

근 1년 들어 Let's encrypt 가 이런 저런 안되는 곳이 좀 있는 것 같아서 인증서를 알아보던 중

 

Zero SSL을 알게 되었다. 인증서 기간은 Let's encrypt 와 같이 3개월동안 무료로 제공!

 

스프링과 vue에 다 적용해주기 위해서 입력해야 하는 명령어들을 정리할 예정이다.

 

일단 Zero SSL에서 인증서를 받으면 다음과 같은 파일들을 준다. 

 

여기 있는 세 개의 파일들은 추후 vue 쪽 설정 잡아주는 파일들과 매칭된다.

zeroSSL -> vue 에서 쓰일 변수

private.key -> privkey.pem

certificate.crt -> cert.pem

ca_bundle.crt -> chain.pem

 

const fs = require("fs");
module.exports = {
    devServer: {
        disableHostCheck : true,
        https: {
            key: fs.readFileSync('/home/dev/code/privkey.pem'),
            cert: fs.readFileSync('/home/dev/code/cert.pem'),
            ca: fs.readFileSync('/home/dev/code/chain.pem'),
        }
    }
}

 

그런데 이렇게 놓고보니 확장자도 맞지 않는다. 

그래서 이 확장자를 변환해주는 과정이 필요 하다.

 

먼저 private.key를 pem으로 변환하려면 아래 명령어!

openssl rsa -in private.key -text > privkey.pem

 

이후 

certificate.crt와 ca_bundle.crt도 pme 으로 변환해줘야 한다.

 

openssl x509 -inform PEM -in certificate.crt > cert.pem
openssl x509 -inform PEM -in ca_bundle.crt > chain.pem

이러면 이제 vue 단에서 필요한 인증서는 뽑은 샘이다.

 

같은 도메인을 사용하고 있고 돌아가는 스프링 부트에도 똑같이 적용해줘야 한다.

요즘에는 jks로 뽑기보다는 .p12 확장자로 뽑아서 쓰는 편이다.

 

p12를 아래 명령어를 통해서 뽑아준다.

openssl pkcs12 -export -in cert.pem -inkey privkey.pem -out cert_and_key.p12 -name tomcat -CAfile chain.pem -caname root

 

yml에 쓰일 친구도 작성해준다.

 

server:
  port: 8080
  ssl:
    enabled: true
    key-store: ../cert_and_key.p12
    key-store-password: yourpassword
    key-store-type: PKCS12

 

 

3개월마다 다시 검색하려니 번거롭기에 메모 남겨둔다..

 

Comments