0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

自己署名証明書の作り方(セキュリティの警告なし)

Posted at

目的

  • セキュリティの警告が出ない自己証明書を作ります。
    ChromeではSAN(Subject Alternative Name)でドメインの一致判定を行うので、SANが設定されるように証明書を作ります。
  • https://192.168.56.120/ に警告なしでアクセスすることを目指します。

参考

手順

1. 差込み情報ファイル作成

証明書作成時にSAN情報を差込むためのファイルを作成します

[root@marmoset ~]# cat san.txt
subjectAltName = DNS:localhost, IP.1:127.0.0.1, IP.2:10.0.2.120, IP.3:192.168.56.120
2. 秘密鍵作成
[root@momonga ~]# openssl genrsa -out localhost.key 2048
3. 証明書署名要求作成

Common Nameを 192.168.56.120 に設定。チャレンジパスワード不要

[root@momonga ~]# openssl req -new -key localhost.key -out localhost.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
Locality Name (eg, city) [Default City]:yokohama
Organization Name (eg, company) [Default Company Ltd]:my-company
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:192.168.56.120
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
4. 自己署名サーバー証明書作成

-extfile オプションで san.txt の情報を差込みます。

[root@marmoset ~]# openssl x509 -req -days 3650 -signkey localhost.key -in localhost.csr -out localhost.crt -extfile san.txt
Certificate request self-signature ok
subject=C = jp, ST = kanagawa, L = yokohama, O = my-company, CN = 192.168.56.120
5. 証明書の内容確認
[root@momonga ~]# openssl x509 -in localhost.crt -text -noout

以下の項目があることを確認する
X509v3 extensions:
X509v3 Subject Alternative Name:
DNS:localhost, IP Address:192.168.56.120, IP Address:127.0.0.1, IP Address:10.0.2.120

6. Apacheの設定

ApacheとSSL/TLS化

9. Chromeに証明書をインストール

localhost.crt をローカルマシンのChromeにインストールします。

  1. localhost.crt をローカルマシンにダウンロードする
  2. Chromeを立ち上げて、メニューの「設定」をクリックする
  3. 左ペインの「プライバシーとセキュリティー」をクリックする
  4. 中央ペインの「セキュリティ」→ 「証明書の管理」の順にクリックする
  5. 「証明書」ウィンドウが開くので、「インポート」ボタンをクリックする
  6. ダウンロードした localhost.crt を選択してインポートする
  7. ブラウザを再起動
  8. https://192.168.56.120/ にアクセスする
  9. セキュリティの警告が出ずにページが表示されればOK
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?