ApacheでSSL自己証明書作成(オレオレ証明書)
1.opensslコマンドでSSL自己証明書を作成する
$ mkdir -p /etc/httpd/conf/ssl.key/
$ mkdir -p /etc/httpd/conf/ssl.crt/
$ cd /etc/httpd/conf/ssl.key/
$ openssl genrsa -aes128 -out server.key 2048
Generating RSA private key, 2048 bit long modulus
...........................................................+++
..................................................................................................................+++
e is 65537 (0x10001)
Enter pass phrase for server.key:パスフレーズ入力
Verifying - Enter pass phrase for server.key:パスフレーズ入力
$ openssl req -new -key server.key -sha256 -out server.csr
Enter pass phrase for server.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]:国名
State or Province Name (full name) [Some-State]:都道府県名
Locality Name (eg, city) []:市町村名
Organization Name (eg, company) [Internet Widgits Pty Ltd]:組織名
Organizational Unit Name (eg, section) []:部門名
Common Name (e.g. server FQDN or YOUR name) []:サイト名
Email Address []:メールアドレス(今回は空白)
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:証明書破棄のパスワード(今回は空白)
An optional company name []:別の組織名(今回は空白)
$ cd /etc/httpd/conf/ssl.crt/
$ openssl x509 -in ../ssl.key/server.csr -days 365 -req -signkey ../ssl.key/server.key -sha256 -out server.crt
Signature ok
subject=/C=AU/ST=Ore/L=city/O=Ore Ltd/OU=Ore Section/CN=ore.com
Getting Private key
Enter pass phrase for server.key:パスフレーズ入力
$ ../ssl.key/
$ mv server.key server.key.back
$ openssl rsa -in server.key.back -out server.key
Enter pass phrase for server.key.back:パスフレーズ入力
writing RSA key
$ cat server.key
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA4q/EHXDS5qNlz+drOIMdeJvaE2dQ67gScg1upB32QwF+gv0J
...
HrO1mZrKkIBZTyZOx9asvn3QjzCVqsRyax2xeZLHNv4Uzryjdg7gsg==
-----END RSA PRIVATE KEY-----
$ cat server.crt
-----BEGIN CERTIFICATE-----
MIIDRDCCAiwCCQD6CXRKYd6N5DANBgkqhkiG9w0BAQsFADBkMQswCQYDVQQGEwJB
...
uQrOisJooN/glYBQUzeqosaLdCWHP9J4
-----END CERTIFICATE-----
$ cat server.csr
-----BEGIN CERTIFICATE REQUEST-----
MIICqTCCAZECAQAwZDELMAkGA1UEBhMCQVUxDDAKBgNVBAgTA09yZTENMAsGA1UE
...
DQ7sNA6T7M4XRLPVOg==
-----END CERTIFICATE REQUEST-----
$ vi /etc/httpd/conf.d/ssl.conf
# SSLCertificateFile /etc/pki/tls/certs/localhost.crt
# SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
SSLCertificateFile /etc/httpd/conf/ssl.crt/server.crt
SSLCertificateKeyFile /etc/httpd/conf/ssl.key/server.key
価格:16,200円 |
コメント