커뮤니티 정보

제목 APACHE 에 open ssl 설정방법
등록자 관리자 등록일 2007.07.26 16:00:11 접속 89733
<아파치 ssl모듈 컴파일 옵션 추가. >

--enable-module=ssl --with-ssl=/usr/local/ssl --enable-ssl=shared


0. 뭐지?
OpenSSL은 : SSL v2/v3와 TLS v1 프로토콜을 지원하는 범용 암호법 라이브러리이다.
대부분 리눅스 배포판에 기본 설치 되어 있음.

1. 개인키생성
1) 3DES 로 암호화(PassPhrase필요)
openssl genrsa -des3 -out 키이름.key 1024

2) 암호화 하지 않음
openssl genrsa -out filename.key 1024

3) 기존 비밀키에 패스워드 추가
openssl rsa -in out 키이름.key -des3 -out 새로운키이름.key

4) 기존 비밀키에 패스워드 제거
openssl rsa -in 키이름.key -out 새로운키이름.key


2. CSR생성 (인증서 서명 요청을 위해 필요)
openssl req -new -key 키이름.key -out CSR이름.csr


3. 자체 서명 인증서 생성하기
openssl req -new -key 키이름.key -x509 -out 인증서이름.crt
openssl req -new -x509 -nodes -sha1 -days 365 -key server.key -out server.crt


4. 인증서 다루는 법
1) 인증서 확인(보기)
openssl x509 -noout -text -in 이증서파일.crt

2) 비밀키 보기
openssl rsa -noout -text -in 키파일.key

#######################
# 설치
#######################
아파치 서버에서 SSL 통신을 가능하기 위해서는 OpenSSL 과 mod_ssl 이 필요하다.



ssl 인증이 뭔지 궁금하시면 옆 메뉴 > 프로그래밍 > 개발 기술문서들 중 181번 글을 참고하면 된다.

http://cafe.naver.com/swingme.cafe?iframe_url=/ArticleList.nhn%3Fclubid=10833428%26menuid=48%26boardtype=L



참고 사이트는

www.openssl.org

www.apache.org

www.modssl.org



선행조건으로는 apache 가 당연히 서버에 설치되어야한다.





1. OpenSSL의 설치




$ gzip -cd openssl-0.9.6.tar.gz | tar xvf -

$ ./config
$ make
$ make install

config에서 prefix를 주지 않았을 때에는 /usr/local/ssl 디렉토리에 설치가 된다.



다른 디렉토리에 설치를 하고자 한다면 다음과 같이 한다.

$ ./config --prefix=/usr/local --openssldir=/usr/local/openssl



OpenSSL의 실행화일은 /usr/local/bin에 설치되고

인증서비스를 위한 화일들은 /usr/local/openssl아래의 디렉토리에 생성된다.





2. Apache + mod_ssl/OpenSSL 설치



$ gzip -cd apache_1.3.19.tar.gz | tar xvf –

$ gzip -cd mod_ssl-2.8.1-1.3.19.tar.gz | tar xvf –



화일의 다운로드와 압축풀기가 끝나면 mod-ssl부터 설정을 한다.



mod-ssl 설정
$ cd mod_ssl-2.8.1-1.3.19

$ ./configure

--with-apache=../apache_1.3.19

--with-ssl=../openssl-0.9.6

--prefix=/usr/local/apache





3. Apache Server 컴파일
OpenSSL, Mod_SSL 설정이 끝났으면, 모든 기능을 아파치서버와 컴파일한다.


$ cd ../apache_1.3.x

$ SSL_BASE=../openssl-0.9.6

./configure

--prefix=/usr/local/apache

--enable-module=ssl

$ make

$ make certificate

$ make install





인증서를 설치한 후에

$ apachectl startssl 명령을 이용하여 아파치를 구동합니다.


#######################
# httpd.conf 설정
#######################

LoadModule ssl_module modules/mod_ssl.so

Listen 80
Listen 443

NameVirtualHost 220.95.230.240:80
NameVirtualHost 220.95.230.240:443


SSLEngine off
....



....

SSLEngine on
SSLCertificateFile conf/ssl/인증서.crt
SSLCertificateKeyFile conf/ssl/개인키파일.key
SSLCertificateChainFile conf/ssl/중계인증서.crt
SetEnvIf User-Agent ".*MSIE.*"
nokeepalive ssl-unclean-shutdown
downgrade-1.0 force-response-1.0
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL



# SSL 을 통해서만 접근할 수 있는 디렉토리 설정.

SSLRequireSSL
....




#######################
# Apache1.x 버전의 httpd 시작
#######################
cd apache/bin
./apachectl startssl

주의) 아파치 SSL 적용후 restart 하시면 ssl 이 반영되지 않습니다.
apachectl stop 후 apachectl startssl 하세요.


#######################
# Apache2.x 버전의 httpd 시작
#######################

4. Apache SSL restart

Apache 웹서버 버젼을 선택해 주시기 바랍니다.
Apache 1.3.xx Apache 2.0.xx $APACHE/bin/apachectl 웹서버 컨트롤 실행 파일이 있습니다. ($APACHE 변수는 아파치 설치 디렉토리를 가르킵니다.)
$APACHE/bin/apachectl startssl 옵션으로 기동합니다. ▣
[root@web1 root]# $APACHE/bin/apachectl startssl
Apache/1.3.31 mod_ssl/2.8.19 (Pass Phrase Dialog)
Some of your private key files are encrypted for security reasons.
In order to read them you have to provide us with the pass phrases.

Server web1:443 (RSA)
Enter pass phrase: [개인키 비밀번호 입력]

Ok: Pass Phrase Dialog successful.
$APACHE/bin/apachectl startssl: httpd started
[root@web1 root]#


이 부분에서 에러로 인해서 $APACHE/bin/apachectl startssl 실행되지 않는다면,
에러로 인해서 재 기동되지 않는다면, error_log 파일의 에러 상태를 파악해 주시고, 애니서트로 문의를 주시기 바랍니다.
간단한 에러 설명과 함께 현재 에러 로그를 리포트해서 애니서트 메일로 통보해 주시기 바랍니다.

$HTTPD/bin/apachectl 웹서버 설정 파일이 있습니다. ($HTTPD 변수는 아파치 설치 디렉토리를 가르킵니다.)
$HTTPD/bin/apachectl -D SSL -k start 옵션으로 기동합니다. ▣
[root@web1 root]# $HTTPD/bin/apachectl -D SSL -k start
Apache/2.0.52 mod_ssl/2.0.52 (Pass Phrase Dialog)
Some of your private key files are encrypted for security reasons.
In order to read them you have to provide us with the pass phrases.

Server web1:443 (RSA)
Enter pass phrase: [개인키 비밀번호 입력]

Ok: Pass Phrase Dialog successful.
[root@web1 root]#


이 부분에서 에러로 인해서 $HTTPD/bin/apachectl -D SSL -k start 실행되지 않는다면,
error_log 파일의 에러 상태를 파악하시고 해결하시기 바랍니다.
애니서트로 문의를 주실 경우에는 간단한 설명과 함께 현재 에러 로그를 애니서트 메일로 통보해 주시기 바랍니다.


5. SSL 구동 확인

Apache 웹서버 버젼을 선택해 주시기 바랍니다.
Apache 1.3.xx Apache 2.0.xx Apache 1.3.xx 웹서버 ssl 모드로 구동된 것을 확인합니다.
($APACHE 변수는 아파치 설치 디렉토리를 가르킵니다.)

1. 프로세스 로딩 확인

[root@web1 root]# ps -ax
PID TTY STAT TIME COMMAND
... ...
11197 ? S 0:00 $APACHE/bin/httpd -DSSL
... ...
11203 pts/1 R 0:00 ps -ax
[root@web1 root]#


이 부분에서 에러로 인해서 $APACHE/bin/httpd -DSSL가 시작되지 않았다면,
error_log 파일의 에러 상태를 파악하시고 해결하시기 바랍니다.
애니서트로 문의를 주실 경우에는 간단한 설명과 함께 현재 에러 로그를 애니서트 메일로 통보해 주시기 바랍니다.

Apache 2.0.xx 웹서버 ssl 모드로 구동된 것을 확인합니다.
($HTTPD 변수는 아파치 설치 디렉토리를 가르킵니다.)

1. 프로세스 로딩 확인

[root@web1 root]# ps -ax
PID TTY STAT TIME COMMAND
... ...
11197 ? S 0:00 $HTTPD/bin/httpd -k start -D SSL
... ...
11203 pts/1 R 0:00 ps -ax
[root@web1 root]#


이 부분에서 에러로 인해서 $HTTPD/bin/httpd -k start -D SSL가 시작되지 않았다면,
error_log 파일의 에러 상태를 파악하시고 해결하시기 바랍니다.
애니서트로 문의를 주실 경우에는 간단한 설명과 함께 현재 에러 로그를 애니서트 메일로 통보해 주시기 바랍니다.


2. 443 포트(HTTPS 통신) 네트웍 활성 확인

[root@web1 root]# netstat -ln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN
... ...
[root@web1 root]#



... 자료없음 ...