OpenSSL の使い方練習: 単純な証明書チェーンを作る - Qiita と同じですが、楕円曲線というのを使うと鍵がすごく短くて済むので試してみました。単に鍵を作るコマンドが違うだけですが後で参考にするためここに載せます。
ルート証明書を作る
鍵を作る
openssl ecparam -name prime256v1 -genkey -noout > root.key
鍵の中を見る
openssl pkey -text -noout < root.key
ルート証明書を作る
openssl req -x509 -days 36500 -subj "/CN=Tama Root CA" -key root.key > root.crt
ルート証明書の中を見る
openssl x509 -text -noout < root.crt
S/MIME 用の証明書を作る
S/MIME 用鍵を作る
openssl ecparam -name prime256v1 -genkey -noout > signer.key
S/MIME 用証明書要求 CRS を作る
openssl req -new -subj "/L=Musashi/CN=kodaira.example.com" -key signer.key > signer.csr
S/MIME 用証明書要求 CRS を確認
openssl req -text -noout < signer.csr
signer.conf という名前で設定ファイルを作る。
basicConstraints = critical,CA:FALSE
keyUsage = critical,digitalSignature,keyEncipherment
extendedKeyUsage = emailProtection
S/MIME 用 CSR をルート証明書で署名する
openssl x509 -req -days 36500 -CA root.crt -CAkey root.key -CAcreateserial -extfile signer.conf < signer.csr > signer.crt
S/MIME 用証明書を確認
openssl x509 -text -noout -purpose < signer.crt