RSA鍵、証明書のファイルフォーマットについて

【概要】

■拡張子

拡張子 形式 備考
.DER バイナリ 鍵や証明書を ASN.1 形式化
.PEM テキスト 鍵や証明書を ASN.1 形式にし、Base64化
.CRT - 証明書
.CER - 証明書
.KEY -
.p12 - PKCS#12個人情報交換ファイル


■鍵の生成方法

鍵の種類 生成コマンド
RSA秘密鍵 openssl genrsa
RSA公開鍵 openssl rsa -in private-key.pem -pubout -out public-key.pem


■鍵の表示方法

鍵の種類 フォーマット 表示コマンド
秘密鍵 PEM openssl rsa -in private-key.pem -text -noout
DER openssl rsa -in private-key.der -inform der -text -noout
公開鍵 PEM openssl rsa -pubin
DER openssl rsa -pubin -inform der


■証明書の表示方法

表示コマンド
openssl x509 -in public-key.crt -text -noout


■証明書から公開鍵を取り出す

コマンド
openssl x509 -in public-key.crt -pubkey


【ブログ】

◆RSA鍵、証明書のファイルフォーマットについて (Qiita, 2014/12/26)
https://qiita.com/kunichiko/items/12cbccaadcbf41c72735


【関連まとめ記事】

全体まとめ
 ◆暗号共通技術 (まとめ)

◆RSA暗号 (まとめ)
https://security-tools.hatenablog.com/entry/rsa

 ◆証明書ツール (まとめ)

◆OpenSSL (まとめ)
https://security-tools.hatenablog.com/entry/OpenSSL


Copyright (C) 谷川哲司 (Tetsuji Tanigawa) 1997 - 2022