윈디하나의 솔라나라: OpenSSL

목차

개요

OpenSSL 설치

아래의 세가지 방법중 어떤것을 사용해도 된다. 솔라나라는 첫번째에 있는 소스 설치방법을 따랐다.

OpenSSL 인증서 만들기

root@wl ~ # cd /usr/local/ssl/certs
root@wl /usr/local/ssl/certs # openssl req -newkey rsa:2048 -nodes -out req.pem -keyout req.key 1)
Generating a 2048 bit RSA private key
.......++++++
.......++++++
writing new private key to '/usr/local/ssl/certs/root.cert'
-----
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]:GyungGiDo
Locality Name (eg, city) []:Suwon
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Solanara
Organizational Unit Name (eg, section) []:SolanaraTeam
Common Name (eg, YOUR name) []:*.solanara.net 2)
Email Address []:admin@solanara.net
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
root@wl /usr/local/ssl/certs # ls -alF 3)
1) OpenSSL 버전이 낮으면 [-newkey rsa:2048]에서 오류가 난다. [-new]로 대체한다.
2) Apache 설정파일인 httpd.conf의 ServerName에 들어갈 값을 적어준다. 아파치는 이부분을 검사한다. www.solanara.net 과 같이 전체를 다 써줘도 되고, 위와 같이 '별표'를 사용할 수 있으며, 192.186.0.1과 같이 IP를 써도 된다. 다른 내용을 쓰면 인증을 다시 받아야 하는 불상사가 생길 수 있다. 유료 루트 인증기관에 보내기 전에 반드시 확인해야 한다.
3) 총 2개의 파일이 생성되었다. req.key는 공개키로, 유출되지 않고 잃어버리지 않도록 보관해야한다. req.pem (certificate signing request)파일은 CA(Certification Authority=인증기관, 예: 베리사인, 타우트)에게 보내 인증 받아야 한다.

Root CA가 되기

CA에서 인증 받으려면 비용이 들기 때문에 테스트용으로는 자신이 CA가 될 필요가 있다. 그런데 CA가 되려면 Root CA(최상위 인증 기관)의 인증이 필요하다. 그리고 그 인증을 받기 위해서는 비용이 든다. 따라서 여기서는 Root CA가 되는 방법을 소개한다. Root CA도 CA중 하나이므로 CA가 하는 일을 모두 할 수 있다.
root@wl /usr/local/ssl/certs # openssl genrsa -des3 -out ca.key 2048 1)
Generating RSA private key, 2048 bit long modulus
............................++++++
............++++++
e is 65537 (0x10001)
Enter pass phrase for ca.key:*****
Verifying - Enter pass phrase for ca.key: *****
root@wl /usr/local/ssl/certs # openssl req -new -x509 -days 365 -key ca.key -out ca.crt 2)
Enter pass phrase for ca.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) [AU]:KR
State or Province Name (full name) [Some-State]:GyungGiDo
Locality Name (eg, city) []:Suwon
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Solanara
Organizational Unit Name (eg, section) []:SolanaraTeam
Common Name (eg, YOUR name) []:Solanara CA
Email Address []:admin@solanara.net
root@wl /usr/local/ssl/certs # openssl x509 -req -CA ca.crt -CAkey ca.key -days 365 -in req.pem -out signed-req.pem -CAcreateserial 3)
Signature ok
subject=/C=KR/ST=GyungGiDo/L=Suwon/O=Solanara/OU=SolanaraTeam/CN=wl.solanara.net/emailAddress=admin@solanara.net
Getting CA Private Key
Enter pass phrase for ca.key:*****
root@wl /usr/local/ssl/certs # chmod 600 *
root@wl /usr/local/ssl/certs # ls -alF 4)
총 18
drwxr-xr-x   2 root     bin          512 10월 26일  13:44 ./
drwxr-xr-x  10 root     bin          512 10월 26일  13:40 ../
-rw-------   1 root     other       1671  4월  8일  11:27 ca.crt
-rw-------   1 root     other       1751  4월  8일  11:26 ca.key
-rw-------   1 root     other         17  4월  8일  11:49 ca.srl
-rw-------   1 root     other       1679  4월  8일  11:48 req.key
-rw-------   1 root     other       1074  4월  8일  11:48 req.pem
-rw-------   1 root     other       1330  4월  8일  11:49 signed-req.pem
root@wl /usr/local/ssl/certs # 
1) Root CA의 2048bit private key 파일을 만든다. 결과 파일은 ca.key 이다.
2) 인증서를 만든다. 결과파일은 ca.crt파일이다. ca.crt를 Internet Explorer에 등록해주면 '올바르지 않은 CA'라는 에러메시지를 없앨 수 있다.
3) 이제 Root CA가 되는 일은 끝났다. 클라이언트가 요청한 req.pem을 싸인해주자. 결과파일은 signed-req.pem이다. 베리싸인과 같은 인증 기관은 이 명령 한줄만 실행 해주면 된다. (그러면서 도대체 얼마를 받는거야... ㅡ,.ㅡ)
4) ca.key와 req.key는 소중하게 보관해야 한다. 절대 외부에 유출되서는 안된다.
※ 아파치를 포함한 유닉스 데몬에서 SSL을 사용할 때 사용하는 필수 정보는, req.key와 signed-req.pem 파일에 저장되어있다. 몇몇 데몬은 ca.crt의 내용까지 요구하는 경우도 있다. (형태가 파일인 경우가 대부분이지만 DB에 저장된 문자열일 수도 있다. 실제로 req.key 와 signed-req.pem 은 vi 에디터등으로 열어 내용을 볼 수 있는 텍스트 파일이다)

정리

인증서를 빨리 생성하기 위한 명령을 정리했다.
root@wl /usr/local/ssl/certs # openssl req -newkey rsa:4096 -nodes -out req.pem -keyout req.key \
  -subj "/C=KR/ST=GyungGiDo/L=Suwon/O=Solanara/OU=SolanaraTeam/CN=*.solanara.net/emailAddress=admin@solanara.net"
root@wl /usr/local/ssl/certs # openssl genrsa -des3 -out ca.key 4096
Enter pass phrase for ca.key:12345
Verifying - Enter pass phrase for ca.key:12345
root@wl /usr/local/ssl/certs # openssl req -new -x509 -days 3650 -key ca.key -out ca.crt \
  -subj "/C=KR/ST=GyungGiDo/L=Suwon/O=Solanara/OU=SolanaraTeam/CN=Solanara CA/emailAddress=admin@solanara.net"
Enter pass phrase for ca.key:12345
root@wl /usr/local/ssl/certs # openssl x509 -req -CA ca.crt -CAkey ca.key -days 3650 -in req.pem -out signed-req.pem -CAcreateserial
Enter pass phrase for ca.key:12345
root@wl /usr/local/ssl/certs #
올바른 XHTML 1.0 Transitional 입니다 올바른 CSS입니다!