Quantcast
Channel: Bash – 2Axels-Company
Viewing all articles
Browse latest Browse all 12

How to show certificate validity period from the Linux command line

$
0
0

Recht oft kommt es bei mir vor, dass ich mal eben kurz herausfinden muss, wie lange ein Zertifikat gültig ist, welches ich als Datei vorliegen habe. Besonders unter Windows ist dies ganz einfach und mit Linux/Unix eigentlich noch einfacher, wenn ich mir immer den Befehl gleich merken könnte…

1
2
3
4
5
6
7
8
9
10
11
user@node:~$ ll
total 16
drwxrws---  2 user user 4096 Apr 16 09:13 .
drwxrws--- 12 user user 4096 Dec  2 07:33 ..
-rw-r--r--  1 user user 2228 Apr 16 09:13 VeriSignClass3InternationalServerCA-G3.cer
-rw-r--r--  1 user user 1758 Apr 16 09:13 VeriSignClass3PublicPrimaryCertificationAuthority-G5.cer
 
user@node:~$ openssl x509 -noout -dates -in VeriSignClass3PublicPrimaryCertificationAuthority-G5.cer 
 
notBefore=Nov  8 00:00:00 2006 GMT
notAfter=Jul 16 23:59:59 2036 GMT

Evtl. kommt bei der Abfrage der Zertifikate ein Fehler:

1
2
unable to load certificate
140221558490952:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:703:Expecting: TRUSTED CERTIFICATE

Dies hat erst einmal nichts damit zu tun, dass hier keine Vertrauensstellung existiert, oder ein Trusted Certificat erwartet wird. Interessanter ist der erste Teil der Fehlermeldung „unable to load certificate„! Es kann das Zertifikat nicht geladen werden, da offentsichtlich das erwartete Format nicht korrekt ist.
Hier hilft dann das folgende Kommando:

1
2
3
4
5
6
7
8
9
10
11
 
$ openssl x509 -noout -text -inform DER -in certname.example.com_20120121.cer
 
$ openssl x509 -noout -text -inform PEM -in certname.example.com_20120121.cer
 
# oder Ausgabe der Datumsfelder:
 
$ openssl x509 -noout -dates -inform DER -in certname.example.com_20120121.cer
 
notBefore=Jan 21 12:40:35 2012 GMT
notAfter=Jan 21 12:40:35 2016 GMT

Weitere Tipps und Tricks findet ihr auf dieser Seite: magenbrot-Wiki – OpenSSL-Zertifikate.


Viewing all articles
Browse latest Browse all 12