Table of Contents
OpenSSL で SSL ワイルドカード自己証明書を発行
公開鍵(csr)作成時にワイルドカードを指定
インストール
# dnf install openssl
秘密鍵の作成
# openssl genrsa -aes128 2048 > /etc/pki/tls/certs/server.key
Generating RSA private key, 2048 bit long modulus (2 primes)
..........................................+++++
...........+++++
e is 65537 (0x010001)
Enter pass phrase:(パスフレーズの入力 )
Verifying - Enter pass phrase:(確認用に再度パスフレーズの入力 )
パスフレーズの削除
# openssl rsa -in /etc/pki/tls/certs/server.key -out /etc/pki/tls/certs/server.key
Enter pass phrase for server.key:(パスフレーズの入力 )
writing RSA key
公開鍵(csr)の作成
# openssl req -utf8 -new -key /etc/pki/tls/certs/server.key -out /etc/pki/tls/certs/server.csr
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]:JP # 国
State or Province Name (full name) []:Kanagawa-ken # 地域(県)
Locality Name (eg, city) [Default City]:Yokohama-shi # 都市
Organization Name (eg, company) [Default Company Ltd]:chinaz.org # 組織名
Organizational Unit Name (eg, section) []: # 組織の部門
Common Name (eg, your name or your server's hostname) []:*.chinaz.org # サーバのFQDN
Email Address []:webmaster@chinaz.org #管理者のアドレス
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: #パスワード (未入力でEnter)
An optional company name []: #確認のパスワード (未入力でEnter)
自己署名証明書を作成
# openssl x509 -in /etc/pki/tls/certs/server.csr -out /etc/pki/tls/certs/server.crt -req -signkey /etc/pki/tls/certs/server.key -days 3650
Signature ok
subject=C = JP, ST = Kanagawa-ken, L = Yokohama-shi, O = chinaz.org, CN = www.chinaz.org, emailAddress = webmaster@chinaz.org
Getting Private key
アクセス権の設定
# chmod 600 /etc/pki/tls/certs/server.key
成果物の確認
# pwd
/etc/pki/tls/certs
# ll
-rw-r--r-- 1 root root 1310 11月 15 11:24 server.crt #デジタル証明書
-rw-r--r-- 1 root root 1050 11月 15 11:14 server.csr #公開鍵
-rw------- 1 root root 1679 11月 15 11:06 server.key #秘密鍵