openssl x509
- 署名済み証明書の内容を確認する。
大枠は -text オプションを指定することになるが、個別にデータを取りたい場合のオプションも含め紹介する。
- 他にも変換や編集、ミニCA機能があるが、変換は兎も角、編集やミニCA機能は使ったことがないので解説しない。
目次
コマンド(-text オプション)
openssl x509 -noout -text -in CRTファイル名.crt
実行結果例(-text オプション)
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
03:e1:0f:20:74:80:01:0b:82:f8:ad:53:39:d8:74:30:4f:02
Signature Algorithm: sha256WithRSAEncryption
Issuer: C=US, O=Let's Encrypt, CN=Let's Encrypt Authority X3
Validity
Not Before: Apr 30 09:08:00 2016 GMT
Not After : Jul 29 09:08:00 2016 GMT
Subject: CN=wiki.ninth-nine.com
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
Modulus:
00:c3:6e:81:a0:ca:e8:d2:6a:b9:f1:ef:23:c2:3e:
80:c6:77:fa:e1:57:89:07:bd:10:16:db:b2:40:e9:
d5:85:24:e5:3f:84:ac:f7:60:07:7a:f7:62:aa:9f:
eb:f5:ee:da:4e:ff:13:06:d7:77:c7:29:dd:7e:89:
68:75:38:ca:5a:10:c6:d5:8e:7a:95:5b:59:90:5b:
59:9c:17:74:69:ea:fe:d7:a9:91:af:01:c6:cb:d9:
95:cc:0b:27:a3:c3:af:f7:eb:e8:e2:3a:99:ba:1a:
9e:fc:db:fe:d5:b7:fd:8e:81:da:ad:79:dd:eb:19:
b2:bb:8a:1d:04:b6:fa:bb:49:4d:a7:e1:43:42:05:
b6:45:1b:83:5f:52:12:d9:97:05:07:ff:92:7a:96:
8d:f3:19:7b:9d:0b:cf:01:54:1c:5d:41:87:5d:11:
e8:d1:9b:03:7a:b3:16:31:55:9f:b5:37:88:93:40:
d6:29:95:df:68:24:e8:6b:5a:f5:50:fc:9b:55:13:
8a:dd:2b:88:19:93:14:de:a7:bc:b5:6a:1c:8f:04:
67:74:6b:fd:b9:ab:56:ca:e7:04:63:63:2c:cc:0a:
cc:f9:cf:b0:58:db:c5:fa:0b:08:ab:6c:5a:5c:9e:
c1:c2:29:72:b0:cb:c3:0b:aa:4f:48:aa:0a:cf:3c:
8a:b1
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Key Usage: critical
Digital Signature, Key Encipherment
X509v3 Extended Key Usage:
TLS Web Server Authentication, TLS Web Client Authentication
X509v3 Basic Constraints: critical
CA:FALSE
X509v3 Subject Key Identifier:
8A:69:F2:2E:DC:EB:A9:23:52:A3:36:3A:3A:D7:2E:B1:A2:D6:37:84
X509v3 Authority Key Identifier:
keyid:A8:4A:6A:63:04:7D:DD:BA:E6:D1:39:B7:A6:45:65:EF:F3:A8:EC:A1
Authority Information Access:
OCSP - URI:http://ocsp.int-x3.letsencrypt.org/
CA Issuers - URI:http://cert.int-x3.letsencrypt.org/
X509v3 Subject Alternative Name:
DNS:wiki.ninth-nine.com
X509v3 Certificate Policies:
Policy: 2.23.140.1.2.1
Policy: 1.3.6.1.4.1.44947.1.1.1
CPS: http://cps.letsencrypt.org
User Notice:
Explicit Text: This Certificate may only be relied upon by Relying Parties and only in accordance with the Certificate Policy found at https://letsencrypt.org/repository/
Signature Algorithm: sha256WithRSAEncryption
45:d6:01:67:fd:77:08:09:c4:42:83:7b:dd:53:eb:89:7f:8c:
d3:8e:e6:f7:e4:17:0b:db:21:a0:aa:e8:64:60:59:b8:cc:0c:
11:3b:34:14:dc:4a:6c:5a:55:1e:57:ff:3c:86:eb:c8:9e:17:
04:92:b7:e0:9c:90:4f:b6:8f:a4:41:fc:3e:f5:9b:78:eb:28:
af:1c:4a:7d:20:ba:76:7e:24:76:cf:d1:16:07:d3:3a:8f:42:
53:5e:dd:74:31:b8:77:43:d5:19:bf:2a:fd:5e:e0:c1:e3:af:
61:fe:7c:0b:01:bb:12:10:c5:64:5a:a6:8b:fb:a9:18:cc:f2:
3c:79:1a:83:be:aa:05:ec:08:2d:05:cc:31:24:ab:81:2c:95:
7c:9c:02:5b:a3:ea:38:3c:b1:38:be:71:df:ec:6a:76:9a:86:
19:8c:02:71:ff:16:40:2f:6e:41:cb:81:44:b8:57:f9:85:ae:
6e:fd:90:32:1f:e8:b5:ed:fb:15:d3:8c:c3:c4:ee:2f:dc:61:
26:81:73:08:06:2d:de:b0:b5:48:07:3e:75:5d:3b:bc:9e:fb:
01:a7:cc:4e:c9:32:2a:99:19:26:2c:78:84:f5:58:04:75:77:
19:f9:a6:e6:2a:e2:7a:73:61:39:df:81:44:91:04:e8:15:61:
05:f5:19:5cこの結果から以下のことがわかる。
署名情報
ラベル名 |
内容 |
意味 |
備考 |
Subject |
CN=wiki.ninth-nine.com |
サブジェクト(主体者)のディスティングイッシュ名 |
|
Issuer |
C=US, O=Let's Encrypt, CN=Let's Encrypt Authority X3 |
イシュア(発行者)のディスティングイッシュ名 |
|
Not Before |
Apr 30 09:08:00 2016 GMT |
有効期限(開始日時) |
|
Not After |
Jul 29 09:08:00 2016 GMT |
有効期限(終了日時) |
|
Public Key Algorithm |
rsaEncryption |
公開鍵暗号アルゴリズムはRSA暗号 |
|
Signature Algorithm |
sha256WithRSAEncryption |
署名アルゴリズムはSHA256でRSA秘密鍵で暗号化したもの |
|
RSA暗号パラメータ
ラベル名 |
内容 |
意味 |
備考 |
Public-Key |
2048 bit |
2048bit 公開鍵 |
|
Modulus |
モジュロ(2048bit 分) |
モジュロ |
|
Exponent |
65537 (0x10001) |
冪指数 |
|
RSA暗号パラメータ(モジュロや冪指数)については以下の文献が詳しい。
属性(Attributes)
ラベル名 |
内容 |
意味 |
備考 |
X509v3 Key Usage |
Digital Signature, Key Encipherment |
証明書の用途(電子署名と鍵暗号) |
|
X509v3 Extended Key Usage |
TLS Web Server Authentication, TLS Web Client Authentication |
証明書の拡張用途(SSLサーバー証明、SSLクライアント証明) |
|
X509v3 Basic Constraints |
CA:FALSE |
証明書チェインの可否(しない) |
|
X509v3 Subject Alternative Name |
DNS:wiki.ninth-nine.com |
SAN |
|
コマンド(-subject/-issuer オプション)
サブジェクト(主体者)やイシュア(発行者)のディスティングイッシュ名を取得する。もちろんオプションは別々に指定可能。
openssl req -noout -subject -issuer -in CRTファイル名.crt
実行結果例(-subject/-issuer オプション)
subject= /CN=wiki.ninth-nine.com issuer= /C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
コマンド(-startdate/-enddate オプション)
有効期限(開始日時あるいは終了日時)を取得する。もちろんオプションは別々に指定可能。
openssl x509 -noout -startdate -enddate -in CRTファイル名.crt
実行結果例(-startdate/-enddate オプション)
notBefore=Apr 30 09:08:00 2016 GMT notAfter=Jul 29 09:08:00 2016 GMT
この場合、notBeforeが-startdateに相当。notAfterが-enddateに対応する。
コマンド(-pubkey オプション)
公開鍵を取得する。取得するだけだと何するの?なので、秘密鍵と対になっているか確認する時に使う(RSA・ECDSA問わず)。
diff -u <(openssl x509 -noout -pubkey -in CRTファイル名.crt) <(openssl pkey -pubout -in 秘密鍵ファイル名.key)
※<(command)というイディオム(実行結果をテンポラリファイル名で渡してくれる)は zsh/bash 拡張なので、シェルスクリプト(sh/ash/ksh)中では使わないこと。
実行結果例(-pubkey オプション)
空の結果が正常。差分が発生した場合、CRTと秘密鍵は一致していない。diff の代わりにcmpを使うでも良い。
