개발자의 노트
반응형

테스트용으로 자체 서명된 SSL 인증서를 만들어보자.
이 글은 How to Create Self-Signed SSL Certificates with OpenSSL에서 대부분 참조했다.


먼저, 개인 키 (.key) 와 인증서 서명 요청 파일 (.csr)을 생성한다.


# openssl req -new -newkey rsa:2048 -nodes -keyout www.xxxx.co.kr.key -out www.*****.co.kr.csr

Generating a 2048 bit RSA private key
…………………………………………..+++
……………………….+++
writing new private key to ‘www.xxxx.co.kr.key’
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [GB]:KR
State or Province Name (full name) [Berkshire]:Seoul
Locality Name (eg, city) [Newbury]:Seoul
Organization Name (eg, company) [My Company Ltd]:xxxx
Organizational Unit Name (eg, section) []:Dev.
Common Name (eg, your name or your server’s hostname) []:www.xxxx.co.kr
Email Address []:xxxx@hanmail.net

Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:123456789
An optional company name []:


이제, csr과 key 파일이 생겼다.


 

# ll

total 8
-rw-r–r– 1 root root 1098 Jun 19 13:00 www.xxxx.co.kr.csr
-rw-r–r– 1 root root 1675 Jun 19 13:00 www.xxxx.co.kr.key


내용을 열람하기 위해서는


# cat www.xxxx.co.kr.csr
# cat www.xxxx.co.kr.key


이제, 자체 서명된 SSL 인증서를 생성한다.


# openssl x509 -req -days 365 -in www.xxxx.co.kr.csr -signkey www.xxxx.co.kr.key -out www.xxxx.co.kr.crt
Signature ok
subject=/C=KR/ST=Seoul/L=Seoul/O=xxxx/OU=Dev./CN=www.xxxx.co.kr/emailAddress=xxxx@hanmail.net
Getting Private key


웹서버 인증서 파일 (.crt) 파일이 만들어졌다.


# ll
total 12
-rw-r–r– 1 root root 1330 Jun 19 13:10 www.xxxx.co.kr.crt
-rw-r–r– 1 root root 1098 Jun 19 13:00 www.xxxx.co.kr.csr
-rw-r–r– 1 root root 1675 Jun 19 13:00 www.xxxx.co.kr.key


아파치 서버가 구동될때마다, 개인 키에 설정된 PassPhrase를 물어보게 되므로
자동으로 모두 처리되도록 하기 위해 PassPhrase를 제거하자.


# cp www.xxxx.co.kr.key www.xxxx.co.kr.key.secure
# openssl rsa -in www.xxxx.co.kr.key.secure -out www.xxxx.co.kr.key
writing RSA key


www.xxxx.co.kr.key.secure 는 안전버전, www.xxxx.co.kr.key 는 비안전버전되겠다.


여기까지가 OpenSSL를 이용해 자체 서명된 SSL 인증서를 만드는 방법이었다.

아파치 서버에 설치하는 부분이 궁금하다면 How to Create Self-Signed SSL Certificates with OpenSSL를 방문해서 확인해볼 수 있겠다.

profile

개발자의 노트

@곽코딩

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!