Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


SSL 인증서 발급

위에서 생성한 root ca 서명키로 SSL 인증서를 발급해 보자

키 쌍 생성

1. SSL 호스트에서 사용할 RSA  key pair(public, private key) 생성

Code Block
languagebash
title2048bit 개인키 생성
openssl genrsa -aes256 -out lesstif.com.key 2048


2. Remove Passphrase from key

Info

개인키를 보호하기 위해 Key-Derived Function 으로 개인키 자체가 암호화되어 있다. 인터넷 뱅킹등에 사용되는 개인용 인증서는 당연히 저렇게 보호되어야 하지만 SSL 에 사용하려는 키가 암호가 걸려있으면 웹 서버 구동때마다 pass phrase 를 입력해야 하므로 암호를 제거한다.

Code Block
languagebash
title개인키 pass phrase 제거
cp  lesstif.com.key  /etc/pki/tls/private/lesstif.com.key.enc
openssl rsa -in  /etc/pki/tls/private/lesstif.com.key.enc -out  /etc/pki/tls/private/lesstif.com.key
Warning
title보안 경고

개인키의 유출 방지를 위해 group 과 other의 permission 을 모두 제거한다.

Code Block
languagebash
chmod 600  /etc/pki/tls/private/lesstif.com.key*

CSR 생성

1. CSR(Certificate Signing Request) 생성을 위한 openssl config 파일을 만들고 host_openssl.conf(변경 가능) 라는 이름으로 저장한다.

Code Block
languagebash
titlehost_openssl.conf
[ req ]
default_bits            = 2048
default_md              = sha1
default_keyfile         = lesstif-rootca.key
distinguished_name      = req_distinguished_name
extensions             = v3_user
## 인증서 요청시에도 extension 이 들어가면 authorityKeyIdentifier 를 찾지 못해 에러가 나므로 막아둔다.
## req_extensions = v3_user

[ v3_user ]
# Extensions to add to a certificate request
basicConstraints = CA:FALSE
authorityKeyIdentifier = keyid,issuer
subjectKeyIdentifier = hash
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
## SSL 용 확장키 필드
extendedKeyUsage = serverAuth,clientAuth
subjectAltName          = @alt_names
[ alt_names]
## Subject AltName의 DNSName field에 SSL Host 의 도메인 이름을 적어준다.
## 멀티 도메인일 경우 *.lesstif.com 처럼 쓸 수 있다.
DNS.1   = www.lesstif.com
DNS.2   = lesstif.com
DNS.3   = *.lesstif.com

[req_distinguished_name ]
countryName                     = Country Name (2 letter code)
countryName_default             = KR
countryName_min                 = 2
countryName_max                 = 2

# 회사명 입력
organizationName              = Organization Name (eg, company)
organizationName_default      = lesstif Inc.
 
# 부서 입력
organizationalUnitName          = Organizational Unit Name (eg, section)
organizationalUnitName_default  = lesstif SSL Project
 
# SSL 서비스할 domain 명 입력
commonName                      = Common Name (eg, your name or your server's hostname)
commonName_default             = lesstif.com
commonName_max                  = 64


...

Code Block
languagebash
openssl req -new -key /etc/pki/tls/private/lesstif.com.key -out /etc/pki/tls/certs/lesstif.com.csr -config host_openssl.conf

...


Code Block
titleSSL 인증서 요청
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) [KR]:
Organization Name (eg, company) [lesstif Inc]:lesstif's Self Signed CA
Common Name (eg, your name or your servers hostname) [lesstif.com]:*.lesstif.com


5년짜리 lesstif.com 용 SSL 인증서 발급 (서명시 ROOT CA 개인키로 서명)

Code Block
languagebash
openssl x509 -req -days 1825 -extensions v3_user -in /etc/pki/tls/certs/lesstif.com.csr \
-CA /etc/pki/tls/certs/lesstif-rootca.crt -CAcreateserial \
-CAkey  /etc/pki/tls/private/lesstif-rootca.key \
-out /etc/pki/tls/certs/lesstif.com.crt  -extfile host_openssl.conf


제대로 생성되었는지 확인을 위해 인증서의 정보를 출력해 본다.

Code Block
languagebash
openssl x509 -text -in lesstif.com.crt


검증이 끝났으면 web server 에서 읽을수 있도록 시스템의 표준 개인키와 인증서 디렉터리에 복사해 준다.

Code Block
languagebash
cp lesstif.com.crt  /etc/pki/tls/certs/
cp lesstif.com.

...

key /etc/pki/tls/private/