Backend&Devops/Nginx

[OpenSSL] SSL 인증서 발급 방법 요약

기은P 2022. 6. 9. 16:15
반응형

1. 개요

웹 서버에 https 적용을 위한 SSL 인증서를 발급 받는 방법을 정리했습니다.

 

 

2. openssl for windows 다운

https://code.google.com/archive/p/openssl-for-windows/downloads

 

Google Code Archive - Long-term storage for Google Code Project Hosting.

 

code.google.com

윈도우에서 SSL 인증서 생성을 위해 위의 링크에 접속해서 프로그램을 다운받습니다.

k, e, d와 같은 라벨이 있는데 저는 e로 다운받고 진행했습니다.

 

 

3. 환경변수 설정

2번에서 압축 파일을 받고 푼 다음, /bin 경로에 있는 openssl.exe를 시스템 환경변수에 등록해줍니다.

 

 

4. private.key 생성

rem AES256으로 암호화된 2048bit 길이의 private key를 생성해줍니다.

openssl genrsa -aes256 -out private.key 2048

사용할 패스워드를 입력해줍니다.

 

Enter pass phrase for private.key: [패스워드 입력]
Verifying - Enter pass phrase for private.key: [패스워드 다시 입력]

 

 

5. public.key 생성

openssl rsa -in private.key -pubout -out public.key

rem private.key를 통해 public.key를 생성해줍니다. 서로 매칭되는 키이기 때문에 4번에서 사용한 패스워드를 똑같이 입력해줍니다.

 

Enter pass phrase for private.key:[패스워드 입력]

 

 

 

6. 인증 서명 요청서(CSR) 생성

openssl req -config ./openssl.cnf -new -key private.key -out private.csr

인증 서명 요청서(CSR)란, 인증기관(CA)을 통해 인증서를 발급받기 위한 정보를 담고 있는 신청서입니다. 인증기관에게 인증서를 받기 위해 서류를 작성하는 신청서라고 생각하시면 됩니다.

 

국가, 도시, 조직 등의 정보인데 개발/배포 용도에 따라 작성해주시면 됩니다.

Country Name (2 letter code) [AU]:KR
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:
Email Address []:

 

rem에 대한 추가정보인데 작성할 필요는 없습니다.
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

 

 

7. 자체 인증 기관(CA) 키 생성

openssl genrsa -aes256 -out root.ca.key 2048

Enter pass phrase for root.ca.key: [패스워드 입력]
Verifying - Enter pass phrase for root.ca.key: [패스워드 다시 입력]

 

 

 

8. 자체 인증기관의 CSR 생성

openssl req -config ./openssl.cnf -x509 -new -nodes -key root.ca.key -days 3650 -out root.ca.pem

 

6번과 마찬가지로 개발/배포 용도에 따라 적당히 작성해주면 됩니다.

Country Name (2 letter code) [AU]:KR
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:
Email Address []:

 

 

9. 자체 인증기관을 통해 인증서(CRT) 발급

openssl x509 -req -in private.csr -CA root.ca.pem -CAkey root.ca.key -CAcreateserial -out private.crt -days 3650

 

7번에서 사용한 rem CA키의 패스워드를 입력합니다.

Enter pass phrase for root.ca.key: [패스워드 입력]

 

 

 

 

10. 최종 산출물

 

 

 

반응형