Kevin Dominic의 Studying Rock Drill~

Apache 2.x에서 SSL Server 구동시키기(CentOS 5.0. 기준) 본문

Study/전공

Apache 2.x에서 SSL Server 구동시키기(CentOS 5.0. 기준)

Kevin Dominic 2009. 12. 8. 17:17
Apache 2.x에서 SSL Server 구동시키기(CentOS 5.0. 기준)

1. Openssl과 httpd가 설치되어 있는지 확인(없으면 설치)

-bash-3.1# yum -y install httpd openssl

.............

2. mod_ssl은 apache 2.x 대부터 라이브러리를 자동으로 읽게 되어있다.

   하지만 정작 라이브러리가 없으므로 라이브러리를 만들어야 한다(업어온다는 표현이 맞겠지만)

  -bash-3.1#  yum -y install mod_ssl

   하면 고맙게도 아파치 모듈 위치에 정확히 꽃혀들어간다. 이렇게 해주면 당연히   SSL 라이브러리를 읽을 수 있다.


3. 아파치 구동 및 포트 테스트

-bash-3.1# service httpd start

Starting httpd...                   [OK]

   ssl이 돌아가는지 확인하려면 다음과 같이 한다.

-bash-3.1# netstat -an | grep 443
                   tcp        0      0 :::443                      :::*                        LISTEN

와 같은 결과가 나오면 443 포트가 열린것이므로 돌아가는 것임

4. 인증서 만들기(이건 사설인증이고, 공인인증을 만드려면 서비스를 신청해야함)

   ex) 여기서는 karbia.com.*의 형태로 파일을 생성하겠음

-bash-3.1# openssl genrsa 1024 > karbia.com.key

Generating RSA private key, 1024 bit long modulus
..............................++++++
..++++++
e is 65537 (0x10001)
-bash-3.1# openssl req -new -key karbia.com.key -out karbia.com.csr
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]:****(도시이름)
Locality Name (eg, city) [Newbury]: ********(알아서 입력할 것)

Organization Name (eg, company) [My Company Ltd]: 내맘대로 회사
Organizational Unit Name (eg, section) []:소속 부서
Common Name (eg, your name or your server's hostname) []:회사의 대표적인 이름

Email Address []:yourmail@yourdomain

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:**********(비밀번호임)
An optional company name []:(생략)
-bash-3.1# cat karbia.com.csr
-----BEGIN CERTIFICATE REQUEST-----
이부분의 내용은 암호화 된 내용이므로 다소 지저분할 수 있어서 생략

-----END CERTIFICATE REQUEST-----
-bash-3.1# openssl x509 -req -days 1280 -in karbia.com.csr -signkey karbia.com.key -out karbia.com.crt


Signature ok
subject=/C=KR/ST=Seoul/L=Eunpyeong Gu NokBun Dong. Hyupjin Bldg./O=Karbia Dev Studio/OU=Dev Part/CN=Karbia Dev St                                            
udio/emailAddress=admin@karbia.com
Getting Private key

 

하면 다음과 같은 결과 키 파일들이 생긴다.


-bash-3.1# ls -al
Total 108
drwxr-xr-x 2 root root  4096  9Sep  2 21:11 .
drwxr-xr-x 4 root root  4096  9Sep  2 18:26 ..
-rw-r--r-- 1 root root  1078  9Sep  2 21:11 karbia.com.crt
-rw-r--r-- 1 root root   814  9Sep  2 21:08 karbia.com.csr
-rw-r--r-- 1 root root   891  9Sep  2 21:06 karbia.com.key
....


5. 인증서를 virtualHost를 이용하여 삽입

일반적인 virtualhost와 기본적인 사용법은 같다. 하지만 SSLEngine을 켜고, 키값을 정의해주는 부분을 추가해야 한다.

아래는 예제이다. httpd.conf 파일에서 다음처럼 수정하면 된다.

-bash-3.1# vi /etc/httpd/conf/httpd.conf

......

### 5. SSL https VirtualHost Configuration
추가시킬 내용
#

#      SSL로 보호하고자 하는 페이지들은 모두 DocumentRoot 하단 디렉토리에 있어야 한다.

#      물론 virtualHost 특성상 다른 도메인을 이용할 경우 각각 정의해 줄 수 있다.
# SSL Engine Switch
# Enable / Disable SSL for this virtual host.
<virtualHost *:80>
        ServerAdmin (yourmail@yourdomain)

        DocumentRoot (ssl을 이용할 문서 페이지들의 디렉토리)

        ServerName (ssl 디렉토리를 부르는 도메인주소 - ssl.yourdomain이 무난할 듯...)

        ServerAlias (ServerName)과 일치시키는 게 편할 듯...

        SSLEngine On
        SSLCertificateFile "(당신의 crt 파일 경로(절대경로로 추가)"
        SSLCertificateKeyFile "(당신의 key 파일 경로(절대경로로 추가)"

</virtualHost>

저장하고 나오면 SSL 인증을 사용할 수 있게 된다.

'Study > 전공' 카테고리의 다른 글

DirectX 7.0 SDK  (0) 2009.12.08
[정보문화사] DirectX 9를 이용한 3d game 프로그래밍 입문 Source  (0) 2009.12.08
3dsmax -> ogre xml conver tools  (0) 2009.12.03
DXSDK7.0A sample  (0) 2009.12.02
3dsxml parser 분석 예제  (0) 2009.11.30