LoginSignup
16
9

More than 5 years have passed since last update.

OpenSSLでX.509 v3の証明書を作成する

Posted at

OpenSSLを勉強して、X.509 v3の証明書を作ってみたかったのでメモ。

extension fileを作成

以下のファイルを作成します。

v3.txt
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment

それぞれの値の意味はここら辺にあります。m(_ _)m
https://www.openssl.org/docs/manmaster/man5/x509v3_config.html

参考サイト
https://stackoverflow.com/questions/18233835/creating-an-x509-v3-user-certificate-by-signing-csr

証明書作成のコマンドを実行

ポイントはopenssl x509コマンドを実行するときに、-extfileオプションを指定することです。
これ「-extfile v3.txt」を追加します。

全体としては、以下のコマンドになります。

$ openssl x509 -in server.csr -req -out server.crt -days 365 -signkey server.key -sha256 -extfile v3.txt

確認...

$ openssl x509 -in server.crt -text | grep Version
        Version: 3 (0x2)
16
9
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
16
9