SSC(Self Signed Certificate)
SSC(Self Signed Certificate)
웹사이트를 개발하다 보면 HTTPS 서비스를 많이 하게 된다. 최근에는 개인정보보호 이슈때문에도 그렇고 보안을 위해 HTTPS는 필수적으로 되어가는 시점에 아무래도 서버에 SSL인증서를 구비하려면 연간 결재도 해야하고 해서 부담이 되는데 테스트를 위해서 하려면 SSC 즉 Self Signed Certificate 개인화 키를 발급 받아서 세팅하면 테스트 어플리케이션 용으로는 충분히 유용하게 사용할 수 있다. 특히 페이스북앱 개발을 하다보면 https 페이지가 필수라 더더욱 유용하다.
# 1. RSA 기반의 private key 생성
$ cd /etc/pki/tls/private
$ openssl genrsa -des3 -out myhostname.key 1024
Generating RSA private key, 1024 bit long modulus
....................++++++
..........................++++++
e is 65537 (0x10001)
Enter pass phrase for myhostname.key:
myhostname.key
생성됨
# 2. 서버 인증서 발급을 위한 요청 파일 CSR(Certificate Signing Request) 생성
custom_openssl.conf 작성
[ req ]
default_bits = 2048
default_md = sha1
default_keyfile = privkey.pem
distinguished_name = req_distinguished_name
[ req_distinguished_name ]
countryName = Seoul
countryName_default = KR
countryName_min = 2
countryName_max = 2
organizationName = (ex. company name)
organizationName_default = company name
organizationUnitName = Division
organizationUnitName_default = Division
commonName = myhostname
commonName_default = myhostname
commonName_max = 64
$ openssl req -new -days 365 -key myhostname.key -out myhostname.csr -config custom_openssl.conf
Enter pass phrase for myhostname.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.
-----
countryName [countryName_default]:
organizationName [organizationName_default]:
myhostname [myhostname]:
myhostname.csr
생성됨
# 3. Key Passphrase 제거
매번 패스워드를 입력하기 번거롭기 때문에 바로 바로 띄울 수 있도록 한다.
$ cp myhostname.key myhostname.enc
$ openssl rsa -in myhostname.enc -out myhostname.key
보안을 위해 permission 제거
$ chmod 600 myhostname.key
# 4. self-signed 인증서 생성(.crt 파일생성)
$ openssl x509 -req -days 365 -in myhostname.csr -signkey myhostname.key -out myhostname.crt
# 5. apache 에 적용하기
/path/to/apache/modules 에 mod_ssl.so 파일을 확인하고 만약 mod_ssl 설치가 안되어 있으면 설치. (centOS 기준 $ yum install mod_ssl
)
ssl.conf 파일에 위에서 만든 키 경로를 설정하고 아파치를 다시 띄운다.
Sent from My Haroopad
The Next Document processor based on Markdown - Download