편집을 취소할 수 있습니다. 이 편집을 되돌리려면 아래의 바뀐 내용을 확인한 후 게시해주세요.
최신판 | 당신의 편집 | ||
1번째 줄: | 1번째 줄: | ||
;How to create a self-signed SSL Certificate | ;How to create a self-signed SSL Certificate | ||
;리눅스 | ;리눅스 개인서명 SSL 인증서 생성 | ||
;리눅스 OpenSSL 인증서 설치 | ;리눅스 OpenSSL 인증서 설치 | ||
==개요== | ==개요== | ||
여기서는 개인 인증기관을 만들고 인증서를 발급받아 보자. 웹브라우저에서는 신뢰할 수 없는 사이트라고 | 여기서는 개인 인증기관을 만들고 인증서를 발급받아 보자. 웹브라우저에서는 신뢰할 수 없는 사이트라고 나오지만, 어쨌든 사용자(웹 접속자)만 동의하면 SSL 기능을 이용할 수 있다. | ||
==확인== | ==확인== | ||
리눅스를 설치했다면 아마도 openssl 패키지가 설치되어 있을 것이다.<ref>리눅스는 SSH 접속을 기본 제공하는데, 거기에도 openssl이 필요하다. [[CentOS 6 최소 설치 패키지 목록]]에도 포함되어 있다.</ref> | 리눅스를 설치했다면 아마도 openssl 패키지가 설치되어 있을 것이다.<ref>리눅스는 SSH 접속을 기본 제공하는데, 거기에도 openssl이 필요하다. [[CentOS 6 최소 설치 패키지 목록]]에도 포함되어 있다.</ref> | ||
< | <source lang='dos'> | ||
[root@ | [root@jmnote ~]# rpm -qa openssl | ||
openssl-1.0.0-20.el6_2.5.x86_64 | openssl-1.0.0-20.el6_2.5.x86_64 | ||
</ | </source> | ||
==개인키 생성== | ==개인키 생성== | ||
< | <source lang='dos'> | ||
[root@ | [root@jmnote ~]# openssl genrsa -des3 -out server.key 2048 | ||
Generating RSA private key, 2048 bit long modulus | Generating RSA private key, 2048 bit long modulus | ||
....................................................................................................................................................................................+++ | ....................................................................................................................................................................................+++ | ||
28번째 줄: | 22번째 줄: | ||
Enter pass phrase for server.key: | Enter pass phrase for server.key: | ||
Verifying - Enter pass phrase for server.key: | Verifying - Enter pass phrase for server.key: | ||
</ | </source> | ||
:→ 서버 개인키인 server.key 파일이 생성된다. | :→ 서버 개인키인 server.key 파일이 생성된다. | ||
==인증요청서 생성== | ==인증요청서 생성== | ||
<source lang='dos'> | |||
< | [root@jmnote ~]# openssl req -new -key server.key -out server.csr | ||
[root@ | |||
Enter pass phrase for server.key: | Enter pass phrase for server.key: | ||
</ | </source> | ||
:→ 서버 개인키 패스워드 입력 | :→ 서버 개인키 패스워드 입력 | ||
< | <source lang='dos'> | ||
You are about to be asked to enter information that will be incorporated | You are about to be asked to enter information that will be incorporated | ||
into your certificate request. | into your certificate request. | ||
53번째 줄: | 46번째 줄: | ||
Common Name (eg, your name or your server's hostname) []:jmnote.com | Common Name (eg, your name or your server's hostname) []:jmnote.com | ||
Email Address []:web@jmnote.com | Email Address []:web@jmnote.com | ||
</ | </source> | ||
:→ 자신의 경우에 맞게 적절히 입력 | :→ 자신의 경우에 맞게 적절히 입력 | ||
< | <source lang='dos'> | ||
Please enter the following 'extra' attributes | Please enter the following 'extra' attributes | ||
to be sent with your certificate request | to be sent with your certificate request | ||
A challenge password []: | A challenge password []: | ||
An optional company name []: | An optional company name []: | ||
</ | </source> | ||
:→ 그냥 {{Enter}}, {{Enter}} | :→ 그냥 {{Enter}}, {{Enter}} | ||
:→ 서버 인증요청서인 server.csr 파일이 생성되었다. | :→ 서버 인증요청서인 server.csr 파일이 생성되었다. | ||
== | ==키에서 패스워드 제거== | ||
키에 패스워드가 들어있으면 아파치 구동시마다 물어본다. 패스워드를 제거하더라도 SSL 암호화 통신에는 문제가 없으므로 제거하자. | |||
<source lang='dos'> | |||
< | [root@jmnote ~]# cp server.key server.key.org | ||
[root@ | [root@jmnote ~]# openssl rsa -in server.key.org -out server.key | ||
[root@ | Enter pass phrase for server.key.org: | ||
Enter pass phrase for server.key. | </source> | ||
</ | |||
:→ 개인키 패스워드를 입력 | :→ 개인키 패스워드를 입력 | ||
< | <source lang='dos'> | ||
writing RSA key | writing RSA key | ||
</ | </source> | ||
:→ 패스워드가 제거된 개인키 파일 server.key 이 생성된다. | :→ 패스워드가 제거된 개인키 파일 server.key 이 생성된다. | ||
< | <source lang='dos'> | ||
[root@ | [root@jmnote ~]# ll server* | ||
-rw-r--r--. 1 root root 1054 Sep 20 07:53 server.csr | -rw-r--r--. 1 root root 1054 Sep 20 07:53 server.csr | ||
-rw-r--r--. 1 root root 1679 Sep 20 07:56 server.key | -rw-r--r--. 1 root root 1679 Sep 20 07:56 server.key | ||
-rw-r--r--. 1 root root 1751 Sep 20 07:55 server.key. | -rw-r--r--. 1 root root 1751 Sep 20 07:55 server.key.org | ||
</ | </source> | ||
:→ 패스워드가 제거된 파일(server.key)은 원래 파일(server.key. | :→ 패스워드가 제거된 파일(server.key)은 원래 파일(server.key.org)에 비해 용량이 조금 줄어들었다. | ||
==인증서 생성== | ==인증서 생성== | ||
<source lang='dos'> | |||
< | [root@jmnote ~]# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt | ||
[root@ | |||
Signature ok | Signature ok | ||
subject=/C=KR/ST=Seoul/L=Yeongdeungpo/O=Jmnote/OU=Jmnote/CN=jmnote.com/emailAddress=web@jmnote.com | subject=/C=KR/ST=Seoul/L=Yeongdeungpo/O=Jmnote/OU=Jmnote/CN=jmnote.com/emailAddress=web@jmnote.com | ||
Getting Private key | Getting Private key | ||
</ | </source> | ||
:→ 서버 인증서인 server. | :→ 서버 인증서인 server.csr이 생성되었다. | ||
==개인키와 인증서 설치== | ==개인키와 인증서 설치== | ||
개인키 파일(.key)과 인증서 파일(.crt)을 ssl이라는 파일명으로 [[httpd.conf 폴더]]에 복사하자. (httpd.conf 폴더는 설정에 따라 다를 수 있다.) | 개인키 파일(.key)과 인증서 파일(.crt)을 ssl이라는 파일명으로 [[httpd.conf 폴더]]에 복사하자. (httpd.conf 폴더는 설정에 따라 다를 수 있다.) | ||
< | <source lang='dos'> | ||
[root@ | [root@jmnote ~]# cp server.key /etc/httpd/conf/ssl.key | ||
[root@ | [root@jmnote ~]# cp server.crt /etc/httpd/conf/ssl.crt | ||
[root@ | [root@jmnote ~]# ll /etc/httpd/conf | ||
total 60 | total 60 | ||
-rw-r--r--. 1 root root 34417 Sep 20 07:41 httpd.conf | -rw-r--r--. 1 root root 34417 Sep 20 07:41 httpd.conf | ||
-rw-r--r--. 1 root root 13139 Feb 14 2012 magic | -rw-r--r--. 1 root root 13139 Feb 14 2012 magic | ||
-rw-r--r--. 1 root root 1298 Sep 20 08:45 | -rw-r--r--. 1 root root 1298 Sep 20 08:45 ssl.crt | ||
-rw-r--r--. 1 root root 1679 Sep 20 08:45 | -rw-r--r--. 1 root root 1679 Sep 20 08:45 ssl.key | ||
</ | </source> | ||
==httpd.conf 설정== | ==httpd.conf 설정== | ||
httpd.conf 파일의 맨 아래에 다음 내용 추가<ref>[[httpd.conf 기본값]]일 때는 그냥 하단에 추가만 하면 되지만, 기존에 VirtualHost를 사용중이라면 적절히 수정해야 한다.</ref> | |||
< | <source lang='bash'> | ||
NameVirtualHost *:443 | NameVirtualHost *:443 | ||
<VirtualHost *:443> | <VirtualHost *:443> | ||
SSLEngine on | SSLEngine on | ||
SSLCertificateFile /etc/httpd/conf/ | SSLCertificateFile /etc/httpd/conf/ssl.crt | ||
SSLCertificateKeyFile /etc/httpd/conf/ | SSLCertificateKeyFile /etc/httpd/conf/ssl.key | ||
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown | SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown | ||
CustomLog logs/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" | CustomLog logs/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" | ||
</VirtualHost> | </VirtualHost> | ||
</ | </source> | ||
==아파치 재시작== | ==아파치 재시작== | ||
<source lang='dos'> | |||
[root@jmnote ~]# service httpd restart | |||
< | |||
[root@ | |||
Stopping httpd: [ OK ] | Stopping httpd: [ OK ] | ||
Starting httpd: [ OK ] | Starting httpd: [ OK ] | ||
</ | </source> | ||
==웹브라우저 테스트== | ==웹브라우저 테스트== | ||
* | *http://111.222.33.44:443 으로 접속하면 | ||
< | <source lang='text'> | ||
Bad Request | |||
Your browser sent a request that this server could not understand. | |||
Reason: You're speaking plain HTTP to an SSL-enabled server port. | |||
Instead use the HTTPS scheme to access this URL, please. | |||
Hint: https://111.222.33.44/ | |||
Apache/2.2.15 (CentOS) Server at 111.222.33.44 Port 443 | |||
... | </source> | ||
</ | |||
==같이 보기== | ==같이 보기== | ||
* [[ | *[[플래시 페이스북 캔버스앱 개발]] | ||
==주석== | ==주석== | ||
<references/> | <references/> | ||
==참고== | ==참고 자료== | ||
*http://www.akadia.com/services/ssh_test_certificate.html | *http://www.akadia.com/services/ssh_test_certificate.html | ||
*http://golmong.tistory.com/112 | *http://golmong.tistory.com/112 | ||
*http://www.jopenbusiness.com/tc/oss/entry/openSSL로-인증서를-만들자 | *http://www.jopenbusiness.com/tc/oss/entry/openSSL로-인증서를-만들자 |