CentOS Stream9に自己署名SSL 証明書を作成する方法

環境
OSバージョンの確認

# cat /etc/redhat-release
CentOS Stream release 9

自己署名の独自SSL証明書作成方法
1.秘密鍵のファイル名の作成

# cd /etc/pki/tls/certs
# openssl genrsa -aes128 2048 > server.key
Enter PEM pass phrase: # サーバ用パスワード入力
Verifying - Enter PEM pass phrase: # 再入力

2.秘密鍵からパスフレーズを削除します

# openssl rsa -in server.key -out server.key
Enter pass phrase for server.key: # サーバ用パスワード入力
writing RSA key

3.サーバ証明書のファイル名の作成

# openssl req -utf8 -new -key server.key -out 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) []:Tokyo  # 都道府県名
Locality Name (eg, city) [Default City]:Tokyo  # 市町村名
Organization Name (eg, company) [Default Company Ltd]:arkgame  # 団体名または会社名
Organizational Unit Name (eg, section) []:arkgame.com # 部署名
Common Name (eg, your name or your server's hostname) []:arkgame.com #	FQDNまたは本装置のIPアドレス
Email Address []:user@arkgame.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

4.有効期限が 10 年の自己署名証明書を作成します

# openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 3650

ファイルの権限を付与します
# chmod 600 server.key

証明書を確認します

# ll server.*
-rw-r--r--. 1 root root 1334 6月 9 06:07 server.crt
-rw-r--r--. 1 root root 1062 6月 9 06:03 server.csr
-rw-------. 1 root root 1704 6月 9 05:58 server.key

 

CentOS Stream 9

Posted by arkgame