ウェブブラウザでオレオレ認証局で作成したサーバ証明書のサイトを閲覧する
の続きです
前回の記事では、GUIを使って Firefox の証明書を操作した。 前回の記事では、NSS を使って CUI で Firefox の証明書を操作する。
NSS
NSS ( Network Security Services ) は セキュリティ対応のクライアントおよびサーバーアプリケーションのクロスプラットフォーム開発をサポートするように設計されたライブラリです。
Firefox は NSSを証明書の管理に使っている。
NSS
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS
macOS では brew コマンドでインストールできる。 https://formulae.brew.sh/formula/nss
certutil
certutilは、NSS データベースファイルを作成および変更できるコマンドラインユーティリティです。 NSS をインストールすると、使えるようになる。
% certutil
certutil - Utility to manipulate NSS certificate databases Usage: certutil-d <database-directory>
NSS を使って Firefox の証明書を操作する
下記を参考にした
certutilでNSS DBを操作する方法
https://qiita.com/tomluck/items/2f8e73ff9ea3d79a3e3dNSS Tools certutil
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/tools/NSS_Tools_certutilHow to Find Your Firefox Profile Folder on Windows, Mac, and Linux
https://www.howtogeek.com/255587/how-to-find-your-firefox-profile-folder-on-windows-mac-and-linux/
macOS では下記にある。
/Users/
/Library/Application Support/Firefox/Profiles/xxxxxxxx.default
注意 : Application と Support の間には空白 (" ") がある。 下記のように ダブルクォーテーション ( " ) で囲むとよい
% ls "/Users/
/Library/Application Support/Firefox/Profiles/"
(2) 証明書の一覧を表示する
% certutil -L -d xxxxxxxx.default
Certificate Nickname Trust Attributes
RapidSSL RSA CA 2018
DigiCert SHA2 Secure Server CA
GTS CA 1O1
(3) 認証局の証明書を追加する
% certutil -A -t "C,," -i cacert.pem -n "hoge CA" -d xxxxxxxx.default
(4) 証明書を確認する
% certutil -L -n "hoge CA" -d xxxxxxxx.default
下記のように表示される。
Certificate:
Issuer: "E=hoge@example.com, CN=hoge CA,OU=hoge section,O=hoge company, L=Yokohama, ST=Kanagawa, C=JP
Validity:
Not Before: Mon Dec 07 04:27:07 2020
Not After : Thu Dec 05 04:27:07 2030
Subject: "E=hoge@example.com, CN=hoge CA,OU=hoge section,O=hoge compay, L=Yokohama, ST=Kanagawa, C=JP
Certificate Trust Flags:
SSL Flags:
Valid CA
Trusted CA
(5) Firefox の GUIを使って 証明書を確認する
下記のように表示される。