고고잉 2023. 1. 1. 19:00

https 접속하기 위해 개인 인증서 만들기 
[root@localhost ~]# rpm -qa openssl (openssl 설치 되어 있는지 확인)
openssl-1.0.1e-42.el6.x86_64
[root@localhost ~]# yum install mod_ssl

[root@localhost ~]# rpm -qa mod_ssl
mod_ssl-2.2.15-47.el6.centos.4.x86_64
[root@localhost ~]# openssl req -nodes -newkey rsa:2048 -keyout a.key -out a.csr
Generating a 2048 bit RSA private key
...........................................................................................+++
......................+++
writing new private key to 'a.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) [XX]:KR
State or Province Name (full name) []:Seoul
Locality Name (eg, city) [Default City]:Gangnam
Organization Name (eg, company) [Default Company Ltd]:a 
Organizational Unit Name (eg, section) []:a
Common Name (eg, your name or your server's hostname) []:a.com
Email Address []:my@a.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[root@localhost ~]# openssl x509 -req -days 365 -in a.csr -signkey a.key -out a.crt
Signature ok
subject=/C=KR/ST=Seoul/L=Gangnam/O=a/OU=a/CN=a.com/emailAddress=my@a.com
Getting Private key

[root@localhost ~]# cp a.crt /etc/pki/tls/certs/a.crt
[root@localhost ~]# cp a.key /etc/pki/tls/private/a.key
[root@localhost ~]# cp a.csr /etc/pki/tls/private/a.csr
[root@localhost ~]# vi /etc/httpd/conf.d/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.  A new
# certificate can be generated using the genkey(1) command.
#SSLCertificateFile /etc/pki/tls/certs/localhost.crt (주석처리)
SSLCertificateFile /etc/pki/tls/certs/a.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 /etc/pki/tls/private/localhost.key (주석 처리)
SSLCertificateKeyFile /etc/pki/tls/private/a.key (추가)

[root@localhost ~]# service httpd restart