SSL証明書の有効期限確認に便利なツール「cert」
こんにちは、コカコーラ大好きカジです。
「SSL証明書(サーバ証明書)の有効期限確認や証明書の種類を確認するのは面倒ですよね。」
OpensslのコマンドをGoogle検索して・・・というか、自分もそんな感じです。
同じな悩みを持った人いそうだなぁ・・・と思って調べたら解決していた人がいました。感謝です。
certとは
SSL証明書(サーバ証明書)の情報取得ツールです。(MITライセンスです。)
genkiroid/cert Cert is the Go tool to get SSL certificate information.
前提条件
MacOSXでの利用法を記載します。他のOSの場合は、Goが動作すれば動くようですので、上記URLのReadmeをご参照ください。
certのセットアップ
brewを利用すれば簡単にインストールできます。
1 2 3 4 | % brew tap genkiroid/homebrew-cert% brew install cert% which cert/usr/local/bin/cert |
certの使い方
発行者、有効期限、コモンネーム(ドメイン名)が分かります。
1 2 3 4 5 6 7 8 9 | % cert dev.classmethod.jpDomainName: dev.classmethod.jpIP: xx.xx.xx.xxIssuer: AmazonNotBefore: 2017-08-01 09:00:00 +0900 JSTNotAfter: 2018-09-01 21:00:00 +0900 JSTCommonName: *.classmethod.jpSANs: [*.classmethod.jp classmethod.jp]Error: |
ELB、Cloudfront、サーバ直接接続などで使う場合
「-k」オプションをつけます。
1 2 3 4 5 6 7 8 9 | % cert -k hogehoge.ap-northeast-1.elb.amazonaws.comDomainName: hogehoge.ap-northeast-1.elb.amazonaws.comIP: xx.xx.xx.xxIssuer: AmazonNotBefore: 2017-08-01 09:00:00 +0900 JSTNotAfter: 2018-09-01 21:00:00 +0900 JSTCommonName: *.classmethod.jpSANs: [*.classmethod.jp classmethod.jp]Error: |
注意:ELB/Cloudfrontは複数IPアドレスを持っていますが、certは1つのみしか表示されません。
便利な機能
これだけ?って思った方、これだけではありません。 「-f」オプションで複数リクエスト可能で、Markdown形式かJSON形式で出力してくれます。 Wikiなどで管理するのに便利ですよね。
1 2 3 4 5 | % cert -f md classmethod.jp dev.classmethod.jpDomainName | IP | Issuer | NotBefore | NotAfter | CN | SANs | Error--- | --- | --- | --- | --- | --- | --- | ---classmethod.jp | xx.xx.xx.xx | Amazon | 2017-07-12 09:00:00 +0900 JST | 2018-08-12 21:00:00 +0900 JST | *.classmethod.jp | \*.classmethod.jp<br/>classmethod.jp<br/> |dev.classmethod.jp | xx.xx.xx.xx | Amazon | 2017-08-01 09:00:00 +0900 JST | 2018-09-01 21:00:00 +0900 JST | *.classmethod.jp | \*.classmethod.jp<br/>classmethod.jp<br/> | |
作成されたMarkdownの表
感動しました。
| DomainName | IP | Issuer | NotBefore | NotAfter | CN | SANs | Error |
|---|---|---|---|---|---|---|---|
| classmethod.jp | xx.xx.xx.xx | Amazon | 2017-07-12 09:00:00 +0900 JST | 2018-08-12 21:00:00 +0900 JST | *.classmethod.jp | *.classmethod.jp classmethod.jp |
|
| dev.classmethod.jp | xx.xx.xx.xx | Amazon | 2017-08-01 09:00:00 +0900 JST | 2018-09-01 21:00:00 +0900 JST | *.classmethod.jp | *.classmethod.jp classmethod.jp |
まとめ
サービス利用しているURLが多数ある場合に、SSL証明書確認や管理などに使えると思います。