이번에는 실제로 브라우저에서 사용하는 Cipher Suite에 대해 테스트 하는 방법을 알아보겠습니다.
5. Key Length 및 유효 기간 설정
cert_gen_rsa.bat 와 cert_gen_dsa.bat 를 편집기로 열어보시면..
SET CADAYS=-days 1095 <Root CA 인증서 유효기간>
SET DAYS=-days 365 <서버 인증서 유효기간>
위 값을 변경하면 인증서의 expire date를 조정할 수 있습니다.
cert_gen_dsa.bat 에서
openssl dsaparam -out dsaparam.pem 2048 에서 2048을 조정하시면 dsa key length를 변경할 수 있으며,
rsa key length의 경우는..
openssl.cnf 파일 내의 default_bits = 1024를 조정하면 됩니다.
6. Cipher Suite 변경해보기
openssl에서 지원하는 cipher suite는 openssl ciphers -v 하시면 볼 수 있습니다.
C:\Apache2\conf\cert>openssl ciphers -v
DHE-RSA-AES256-SHA SSLv3 Kx=DH Au=RSA Enc=AES(256) Mac=SHA1
DHE-DSS-AES256-SHA SSLv3 Kx=DH Au=DSS Enc=AES(256) Mac=SHA1
AES256-SHA SSLv3 Kx=RSA Au=RSA Enc=AES(256) Mac=SHA1
EDH-RSA-DES-CBC3-SHA SSLv3 Kx=DH Au=RSA Enc=3DES(168) Mac=SHA1
EDH-DSS-DES-CBC3-SHA SSLv3 Kx=DH Au=DSS Enc=3DES(168) Mac=SHA1
DES-CBC3-SHA SSLv3 Kx=RSA Au=RSA Enc=3DES(168) Mac=SHA1
DES-CBC3-MD5 SSLv2 Kx=RSA Au=RSA Enc=3DES(168) Mac=MD5
DHE-RSA-AES128-SHA SSLv3 Kx=DH Au=RSA Enc=AES(128) Mac=SHA1
DHE-DSS-AES128-SHA SSLv3 Kx=DH Au=DSS Enc=AES(128) Mac=SHA1
AES128-SHA SSLv3 Kx=RSA Au=RSA Enc=AES(128) Mac=SHA1
IDEA-CBC-SHA SSLv3 Kx=RSA Au=RSA Enc=IDEA(128) Mac=SHA1
IDEA-CBC-MD5 SSLv2 Kx=RSA Au=RSA Enc=IDEA(128) Mac=MD5
RC2-CBC-MD5 SSLv2 Kx=RSA Au=RSA Enc=RC2(128) Mac=MD5
RC4-SHA SSLv3 Kx=RSA Au=RSA Enc=RC4(128) Mac=SHA1
RC4-MD5 SSLv3 Kx=RSA Au=RSA Enc=RC4(128) Mac=MD5
RC4-MD5 SSLv2 Kx=RSA Au=RSA Enc=RC4(128) Mac=MD5
EDH-RSA-DES-CBC-SHA SSLv3 Kx=DH Au=RSA Enc=DES(56) Mac=SHA1
EDH-DSS-DES-CBC-SHA SSLv3 Kx=DH Au=DSS Enc=DES(56) Mac=SHA1
DES-CBC-SHA SSLv3 Kx=RSA Au=RSA Enc=DES(56) Mac=SHA1
DES-CBC-MD5 SSLv2 Kx=RSA Au=RSA Enc=DES(56) Mac=MD5
EXP-EDH-RSA-DES-CBC-SHA SSLv3 Kx=DH(512) Au=RSA Enc=DES(40) Mac=SHA1 export
EXP-EDH-DSS-DES-CBC-SHA SSLv3 Kx=DH(512) Au=DSS Enc=DES(40) Mac=SHA1 export
EXP-DES-CBC-SHA SSLv3 Kx=RSA(512) Au=RSA Enc=DES(40) Mac=SHA1 export
EXP-RC2-CBC-MD5 SSLv3 Kx=RSA(512) Au=RSA Enc=RC2(40) Mac=MD5 export
EXP-RC2-CBC-MD5 SSLv2 Kx=RSA(512) Au=RSA Enc=RC2(40) Mac=MD5 export
EXP-RC4-MD5 SSLv3 Kx=RSA(512) Au=RSA Enc=RC4(40) Mac=MD5 export
EXP-RC4-MD5 SSLv2 Kx=RSA(512) Au=RSA Enc=RC4(40) Mac=MD5 export
이것을 참조하시어 C:\Apache2\conf\extra\httpd-ssl.conf 에 있는 다음 항목을 수정하면 됩니다.
다음은 TLS_RSA_EXPORT_WITH_RC4_40_MD5 만을 서버가 지원하겠다는 설정입니다.
# SSL Cipher Suite:
# List the ciphers that the client is permitted to negotiate.
# See the mod_ssl documentation for a complete list.
#SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCipherSuite EXP-RC4-MD5
저장 후 종료...
Apache를 Restart 하면 적용됩니다.
주의사항: 위 Cipher Suite 중 Au가 DSS로 되어 있는 것을 테스트하기 위해서는 인증키도 반드시 DSA 키로 만들어야 합니다!
이 정도면 간단히 브라우저에서 지원하는 SSL/TLS 테스트를 할 수 있으리라고 판단됩니다.
'TLS'에 해당되는 글 3건
- [2007/07/05] Apache + SSL (for Windows) 환경 구축 3/3 (2)
- [2007/07/05] Apache + SSL (for Windows) 환경 구축 2/3
- [2007/07/05] Apache + SSL (for Windows) 환경 구축 1/3
cert_gen_dsa.bat을 실행합니다. rsa와 거의 동일합니다..
DSA를 이용한 인증서는 TLS_DSS_... TLS_DHE_DSS 등의 Cipher Suite를 이용할 때 필요합니다.
4. Apache + SSL 환경 설정
C:\Apache2\conf\httpd.conf를 편집기로 열어서 다음과 같이 편집합니다.
#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
...
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule ssl_module modules/mod_ssl.so <앞에 있는 #을 없애줍니다...>
...
# Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf<앞에 있는 #을 없애줍니다...>
저장 후 종료..
C:\Apache2\conf\extra\httpd-ssl.conf를 편집기로 열어서 다음과 같이 편집합니다.
# Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate. If
# the certificate is encrypted, then you will be prompted for a
# pass phrase. Note that a kill -HUP will prompt again. Keep
# in mind that if you have both an RSA and a DSA certificate you
# can configure both in parallel (to also allow the use of DSA
# ciphers, etc.)
#SSLCertificateFile c:/Apache2/conf/server.crt
#SSLCertificateFile c:/Apache2/conf/server-dsa.crt
SSLCertificateFile c:/Apache2/conf/cert/my-server.crt
# Server Private Key:
# If the key is not combined with the certificate, use this
# directive to point at the key file. Keep in mind that if
# you've both a RSA and a DSA private key you can configure
# both in parallel (to also allow the use of DSA ciphers, etc.)
#SSLCertificateKeyFile c:/Apache2/conf/server.key
#SSLCertificateKeyFile c:/Apache2/conf/server-dsa.key
SSLCertificateKeyFile c:/Apache2/conf/cert/my-server.key
위 처럼 기존에 설정된 것은 #으로 주석처리 하고 우리가 앞 과정에서 생성한 서버 인증서와 키를 등록합니다.
저장 후 종료..
Apache를 Start(또는 Restart) 합니다. 브라우저에서 https://localhost 를 입력해 봅니다. (Apache 설정에 따라 다를 수 있음)
공인된 업체에서 발급한 인증서가 아니고 어쩌고.. 경고 뜨면서 접속이 가능하면 일단 성공입니다!
테스트를 위한 다른 세팅은 3부에서...
브라우저의 Secure Socket Layer 테스트를 위해 Local에 Apache + SSL 환경을 구축하였습니다.
해당 사항은 Win32 기반으로 테스트를 하였고, Linux 등의 환경에서도 크게 다르지 않을 것이라 판단됩니다.
1. Apache + SSL 배포판 구하기
공식 Apache 홈페이지에는 Windows용의 경우 noSSL 버전만 배포하고 있습니다. 그러나 다음 위치에서 받을 수 있습니다.
- http://mirror.apache-kr.org/httpd/binaries/win32/ 의 apache_x.x.x-win32-x86-openssl-0.x.xx.msi 형태의 설치 파일
- http://hunter.campbus.com/ 에서 배포하는 파일
2. Apache + SSL 설치하기
일반 Apache와 동일한 설치 과정을 거칩니다. 여기에서는 C:\Apache2에 설치했다고 가정합니다.
C:\Apache2\conf의 httpd.conf 파일을 환경에 맞게 기본 세팅합니다.
C:\Apache2\bin을 환경 변수 Path에 추가합니다.
3. OpenSSL을 이용하여 인증서 생성하기
SSL을 이용하려면 인증서를 생성하여야 합니다.
C:\Apache2\conf\cert 폴더를 만들고 첨부한 Apache-ssl-cert.zip을 압축 해제 합니다.
제가 테스트 해보면서 만든 인증서, 키, 배치 파일 등이 있습니다.
OpenSSL의 기본 세팅은 openssl.cnf 파일에 있습니다. (바로가기로 인식하여 확장자 cnf가 안보일 수 있습니다)
3.1 RSA 인증서 생성
cert_gen_rsa.bat 을 실행합니다. OpenSSL 명령어 일일이 치기 귀찮아 만든 배치 파일입니다.
C:\Apache2\conf\cert>cert_gen_rsa
C:\Apache2\conf\cert>SET REQ=openssl req
C:\Apache2\conf\cert>SET CA=openssl ca
C:\Apache2\conf\cert>SET SSL_CNF=-config openssl.cnf
C:\Apache2\conf\cert>SET CATOP=.\demoCA
C:\Apache2\conf\cert>SET CAKEY=cakey.pem
C:\Apache2\conf\cert>SET CAREQ=careq.pem
C:\Apache2\conf\cert>SET CACERT=cacert.pem
C:\Apache2\conf\cert>SET CADAYS=-days 1095
C:\Apache2\conf\cert>SET DAYS=-days 365
C:\Apache2\conf\cert>echo -----------------------------------------
-----------------------------------------
C:\Apache2\conf\cert>echo Making CA certificate ...
Making CA certificate ...
C:\Apache2\conf\cert>echo -----------------------------------------
-----------------------------------------
// CA 인증서를 만듭니다. Verisign 등에서 배포하는 공인인증서 등을 만드는 작업입니다.
C:\Apache2\conf\cert>openssl req -config openssl.cnf -new -keyout .\demoCA\priva
te\cakey.pem -out .\demoCA\careq.pem
Loading 'screen' into random state - done
Generating a 1024 bit RSA private key
...++++++
................................++++++
writing new private key to '.\demoCA\private\cakey.pem'
Enter PEM pass phrase:<Root CA 개인키를 생성하기 위한 비밀번호를 입력합니다.>
Verifying - Enter PEM pass phrase:<Root CA 개인키를 생성하기 위한 비밀번호를 입력합니다.>
-----
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) [AU]:KR (그다지 중요하지 않지만 아래 사항 전부 기입합니다)
State or Province Name (full name) [Some-State]:SEOUL
Locality Name (eg, city) []:SEOUL
Organization Name (eg, company) [Internet Widgits Pty Ltd]:TEST COMPANY
Organizational Unit Name (eg, section) []:CERT
Common Name (eg, YOUR name) []:Cert
Email Address []:cert@test.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: <Enter>
An optional company name []: <Enter>
C:\Apache2\conf\cert>openssl ca -config openssl.cnf -create_serial -out .\demoCA
\cacert.pem -days 1095 -batch -keyfile .\demoCA\private\cakey.pem -selfsign -ext
ensions v3_ca -infiles .\demoCA\careq.pem
Using configuration from openssl.cnf
Loading 'screen' into random state - done
Enter pass phrase for .\demoCA\private\cakey.pem:<Root CA를 생성시 사용한 비밀번호를 입력합니다.>
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number: 17 (0x11)
Validity
Not Before: Jul 5 05:14:19 2007 GMT
Not After : Jul 4 05:14:19 2010 GMT
Subject:
countryName = KR
stateOrProvinceName = SEOUL
organizationName = TEST COMPANY
organizationalUnitName = CERT
commonName = Cert
emailAddress = cert@test.com
X509v3 extensions:
X509v3 Subject Key Identifier:
05:D8:6E:9E:7C:1C:C3:2F:3A:30:3F:E4:76:D2:9D:7F:F4:DB:06:BC
X509v3 Authority Key Identifier:
keyid:05:D8:6E:9E:7C:1C:C3:2F:3A:30:3F:E4:76:D2:9D:7F:F4:DB:06:B
C
DirName:/C=KR/ST=SEOUL/O=TEST COMPANY/OU=CERT/CN=Cert/emailAddre
ss=cert@test.com
serial:11
X509v3 Basic Constraints:
CA:TRUE
Certificate is to be certified until Jul 4 05:14:19 2010 GMT (1095 days)
Write out database with 1 new entries
Data Base Updated
C:\Apache2\conf\cert>echo -----------------------------------------
-----------------------------------------
C:\Apache2\conf\cert>echo Making Server certificate ...
Making Server certificate ...
C:\Apache2\conf\cert>echo -----------------------------------------
-----------------------------------------
// 서버에서 사용할 인증서를 만듭니다.
C:\Apache2\conf\cert>openssl req -config openssl.cnf -new -keyout newkey.pem -ou
t newreq.pem -days 365
Loading 'screen' into random state - done
Generating a 1024 bit RSA private key
.........++++++
...........................++++++
writing new private key to 'newkey.pem'
Enter PEM pass phrase:<서버의 개인키 생성을 위한 비밀 번호 입력>
Verifying - Enter PEM pass phrase:<서버의 개인키 생성을 위한 비밀 번호 입력>
-----
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) [AU]:KR <빈 항목 없이 대충 입력 합니다.>
State or Province Name (full name) [Some-State]:Seoul
Locality Name (eg, city) []:Seoul
Organization Name (eg, company) [Internet Widgits Pty Ltd]:ddula
Organizational Unit Name (eg, section) []:ddula
Common Name (eg, YOUR name) []:localhost <서버의 Domain 주소나 IP 주소와 일치하도록>
Email Address []:ddula@naver.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: <Enter>
An optional company name []: <Enter>
// 앞서 생성한 Root CA로 서버의 인증서를 서명을 합니다.
C:\Apache2\conf\cert>openssl ca -config openssl.cnf -policy policy_anything -out
newcert.pem -extensions v3_ca -infiles newreq.pem
Using configuration from openssl.cnf
Loading 'screen' into random state - done
Enter pass phrase for ./demoCA/private/cakey.pem:<Root CA 개인키를 생성시 사용한 비밀번호 입력>
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number: 18 (0x12)
Validity
Not Before: Jul 5 05:14:56 2007 GMT
Not After : Jul 4 05:14:56 2008 GMT
Subject:
countryName = KR
stateOrProvinceName = Seoul
localityName = Seoul
organizationName = ddula
organizationalUnitName = ddula
commonName = localhost
emailAddress = ddula@naver.com
X509v3 extensions:
X509v3 Subject Key Identifier:
D5:59:04:5E:BD:54:2A:14:06:2B:F2:48:30:CB:21:8B:DC:D9:86:88
X509v3 Authority Key Identifier:
keyid:05:D8:6E:9E:7C:1C:C3:2F:3A:30:3F:E4:76:D2:9D:7F:F4:DB:06:B
C
DirName:/C=KR/ST=SEOUL/O=TEST COMPANY/OU=CERT/CN=Cert/emailAddre
ss=cert@test.com
serial:11
X509v3 Basic Constraints:
CA:TRUE
Certificate is to be certified until Jul 4 05:14:56 2008 GMT (365 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
C:\Apache2\conf\cert>echo -----------------------------------------
-----------------------------------------
C:\Apache2\conf\cert>echo Making cerificate for Apache ...
Making cerificate for Apache ...
C:\Apache2\conf\cert>echo -----------------------------------------
-----------------------------------------
// Apache 에서 사용할 수 있는 형태로 변환합니다.
C:\Apache2\conf\cert>openssl rsa -in newkey.pem -out my-server.key
Enter pass phrase for newkey.pem:<서버의 개인키 생성 시 사용한 비밀 번호 입력>
writing RSA key
C:\Apache2\conf\cert>copy newcert.pem my-server.crt
1개 파일이 복사되었습니다.
C:\Apache2\conf\cert>
이로써 RSA를 이용한 인증서 제작을 위한 기본적인 작업은 모두 끝났습니다.
my-server.key는 서버의 개인키이며, my-server.crt는 Root CA의 서명을 받은 서버 인증서 입니다.
openssl x509 -in cacert.pem -out cacert.der.crt -outform DER
2부에서 계속...
Apache-ssl-cert.zip

::: 사람과 사람의 교감! 人터넷의 첫 시작! 댓글을 달아주세요! :::
conf 파일에서 다음과 같이 하면 경로별로 지원하는 Cipher Suite를 다르게 가져갈 수 있습니다.
# be liberal in general
SSLCipherSuite ALL:!ADH:RC4 RSA: HIGH: MEDIUM: LOW: SSLv2: EXP: eNULL
<Location /strong/area>
# but https://hostname/strong/area/ and below requires strong ciphers
SSLCipherSuite HIGH:MEDIUM
</Location>
http://www.modssl.org 가시면 사용법이 자세히 나와 있으니 참고하세요..