証明書の形式を変換するには、形式に応じて openssl.exe を次のように使用します。
openssl pkcs7 -inform DER -in filename.p7b -text -print_certs -out outfilename.pem
次に例を示します。
openssl pkcs7 -inform DER -in IECert.p7b -text -print_certs -out IECert.pem
openssl pkcs7 -inform DER -in filename.p7b -text -print_certs -out outfilename.pem
例:
openssl pkcs7 -inform DER -in IECert.p7b -text -print_certs -out IECert.pem
複数の証明書を 1 つのファイルで処理する場合、説明のテキスト コンテンツにスペースが必要になることが問題になる場合があります。このような場合、テキスト コンテンツを削除することもできますが、通常は推奨されません。それらのコンテンツをすぐに確認できないと、証明書の処理が面倒になるためです。
アプリケーションによっては、証明書ファイルにテキストの説明が含まれていると X509v3 証明書が受け入れられないことがあります。ほとんどのアプリケーションでは、証明書を編集してテキストのセクションを削除することで対処できますが、バイナリ証明書データの開始および終了を示す行は残す必要があることに注意してください。
openssl pkcs12 -export -in pem-cert-and-key-file -out pkcs12-cert-and-key-file
openssl pkcs12 -export -in pem-cert-file -inkey pem-key-file -out pkcs12-cert-and-key-file
どちらのコマンドでも、証明書およびキー ファイルが 1 つのファイルに格納されます。プライベート キーおよび証明書をこのように一緒に格納する場合は、生成されるファイルにパス フレーズを適用する必要があります。
PKCS#12 を PEM に変換するには、次のコマンドを使用します。
openssl pkcs12 -in pkcs-12-cert-and-key-file -out pem-cert-and-key-file
openssl dsa -inform PEM -outform DER -in pem-file -out der-file
openssl rsa -inform PEM -outform DER -in pem-file -out der-file
openssl dsa -inform DER -outform PEM -in der-file -out pem-file
openssl rsa -inform DER -outform PEM -in der-file -out pem-file