Difference between revisions of "Letsencrypt/openssl"

From Hackerspace.gr
Jump to: navigation, search
Line 1: Line 1:
 
 
== Useful Commands ==
 
== Useful Commands ==
 
 
  
 
=== OpenSSL ===  
 
=== OpenSSL ===  
  
 
notes based on '''CentOS''' 6.7
 
notes based on '''CentOS''' 6.7
 
 
 
  
 
Τα πιστοποιητικά (certificates) ονομάζονται x509
 
Τα πιστοποιητικά (certificates) ονομάζονται x509
  
 +
==== View a x509 ====
  
 
Πως μπορούμε να δούμε το πιστοποιητικό ενός site
 
Πως μπορούμε να δούμε το πιστοποιητικό ενός site
Line 21: Line 16:
  
 
</pre>
 
</pre>
 
  
 
Το πιστοποιητικό είναι μεταξύ του  
 
Το πιστοποιητικό είναι μεταξύ του  
Line 31: Line 25:
 
</pre>
 
</pre>
  
 +
==== Text Output ====
  
 
Μπορούμε να μετατρέψουμε το πιστοποιητικό σε text output για να πάρουμε περισσότερες πληροφορίες, όπως πότε λήγει:
 
Μπορούμε να μετατρέψουμε το πιστοποιητικό σε text output για να πάρουμε περισσότερες πληροφορίες, όπως πότε λήγει:
Line 38: Line 33:
 
</pre>
 
</pre>
  
 
+
==== Date Expiration ====
ή
+
  
 
<pre>
 
<pre>
Line 46: Line 40:
 
             Not Before: Jun 12 17:55:50 2015 GMT
 
             Not Before: Jun 12 17:55:50 2015 GMT
 
             Not After : Jun 13 05:21:51 2017 GMT
 
             Not After : Jun 13 05:21:51 2017 GMT
 
 
</pre>
 
</pre>
  
 +
==== Chain ====
  
 
Πως μπορούμε να δούμε, ποιος έχει εκδόσει το πιστοποιητικό και ποιοι οργανισμοί έχουν υπογράψει
 
Πως μπορούμε να δούμε, ποιος έχει εκδόσει το πιστοποιητικό και ποιοι οργανισμοί έχουν υπογράψει
Line 54: Line 48:
 
<pre>
 
<pre>
 
$ openssl s_client -connect hackerspace.gr:443  </dev/null  | grep ^depth
 
$ openssl s_client -connect hackerspace.gr:443  </dev/null  | grep ^depth
 
 
  
 
depth=2 C = IL, O = StartCom Ltd., OU = Secure Digital Certificate Signing, CN = StartCom Certification Authority
 
depth=2 C = IL, O = StartCom Ltd., OU = Secure Digital Certificate Signing, CN = StartCom Certification Authority
Line 64: Line 56:
  
 
DONE
 
DONE
 
 
  
 
Το depth=0 είναι το πιστοποιητικό μας,  
 
Το depth=0 είναι το πιστοποιητικό μας,  
 
το depth=1 είναι ο intermediate  
 
το depth=1 είναι ο intermediate  
 
το depth=2 είναι o root Certificate Authority
 
το depth=2 είναι o root Certificate Authority
 
 
  
 
</pre>
 
</pre>
  
 
+
==== intermediates ====
 
+
  
 
Πως βλέπουμε όλα τα πιστοποιητικά από ένα site (δλδ το δικό του και των intermediates):
 
Πως βλέπουμε όλα τα πιστοποιητικά από ένα site (δλδ το δικό του και των intermediates):
 
  
 
<pre>
 
<pre>
Line 86: Line 72:
  
 
</pre>
 
</pre>
 
  
 
save them all to a file:
 
save them all to a file:
Line 93: Line 78:
  
 
$ openssl s_client -showcerts -connect hackerspace.gr:443 </dev/null | sed -n '/BEGIN/,/END/p' > /tmp/certs
 
$ openssl s_client -showcerts -connect hackerspace.gr:443 </dev/null | sed -n '/BEGIN/,/END/p' > /tmp/certs
 
  
 
</pre>
 
</pre>
 
 
  
 
save the first certificate (site certificate) to a file:
 
save the first certificate (site certificate) to a file:
Line 104: Line 86:
 
$ openssl s_client -showcerts -connect hackerspace.gr:443 </dev/null | sed -n '/BEGIN/,/END/p;/END/q'  > /tmp/hackerspace.crt
 
$ openssl s_client -showcerts -connect hackerspace.gr:443 </dev/null | sed -n '/BEGIN/,/END/p;/END/q'  > /tmp/hackerspace.crt
 
</pre>
 
</pre>
 
  
 
verify it:
 
verify it:
 
  
 
<pre>
 
<pre>
Line 114: Line 94:
  
 
</pre>
 
</pre>
 
  
 
verify chain  
 
verify chain  
 
  
 
<pre>
 
<pre>
Line 126: Line 104:
  
 
</pre>
 
</pre>
 
 
 
  
 
----
 
----
  
 
+
=== Let's Encrypt ===  
=== Let's Encrypt ===  
+
 
+
 
+
  
 
O client του Let's Encrypt θέλει python 2.7  
 
O client του Let's Encrypt θέλει python 2.7  
  
 
Σε CentOS 6 έχει by default python 2.6
 
Σε CentOS 6 έχει by default python 2.6
 
  
 
Οπότε παρακάτω είναι μερικές
 
Οπότε παρακάτω είναι μερικές

Revision as of 09:44, 29 March 2016

Useful Commands

OpenSSL

notes based on CentOS 6.7

Τα πιστοποιητικά (certificates) ονομάζονται x509

View a x509

Πως μπορούμε να δούμε το πιστοποιητικό ενός site


$ openssl s_client -connect hackerspace.gr:443  </dev/null

Το πιστοποιητικό είναι μεταξύ του

-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----

Text Output

Μπορούμε να μετατρέψουμε το πιστοποιητικό σε text output για να πάρουμε περισσότερες πληροφορίες, όπως πότε λήγει:

$ openssl x509 -text -in <(openssl s_client -connect hackerspace.gr:443)

Date Expiration

$ openssl x509 -text -in <(openssl s_client -connect hackerspace.gr:443) | grep -E 'Not Before|Not After'

            Not Before: Jun 12 17:55:50 2015 GMT
            Not After : Jun 13 05:21:51 2017 GMT

Chain

Πως μπορούμε να δούμε, ποιος έχει εκδόσει το πιστοποιητικό και ποιοι οργανισμοί έχουν υπογράψει

$ openssl s_client -connect hackerspace.gr:443  </dev/null  | grep ^depth

depth=2 C = IL, O = StartCom Ltd., OU = Secure Digital Certificate Signing, CN = StartCom Certification Authority

depth=1 C = IL, O = StartCom Ltd., OU = Secure Digital Certificate Signing, CN = StartCom Class 2 Primary Intermediate Server CA

depth=0 C = GR, ST = Attica, L = Filadelfeia, O = Pierros Papadeas, CN = *.hackerspace.gr, emailAddress = postmaster@hackerspace.gr

DONE

Το depth=0 είναι το πιστοποιητικό μας, 
το depth=1 είναι ο intermediate 
το depth=2 είναι o root Certificate Authority

intermediates

Πως βλέπουμε όλα τα πιστοποιητικά από ένα site (δλδ το δικό του και των intermediates):


$ openssl s_client -showcerts -connect hackerspace.gr:443 </dev/null

save them all to a file:


$ openssl s_client -showcerts -connect hackerspace.gr:443 </dev/null | sed -n '/BEGIN/,/END/p' > /tmp/certs

save the first certificate (site certificate) to a file:

$ openssl s_client -showcerts -connect hackerspace.gr:443 </dev/null | sed -n '/BEGIN/,/END/p;/END/q'  > /tmp/hackerspace.crt

verify it:


$ openssl x509 -text -in /tmp/hackerspace.crt

verify chain


$ openssl verify -CAfile <(cat /etc/pki/tls/certs/ca-bundle.crt /tmp/certs ) /tmp/hackerspace.crt 

/tmp/hackerspace.crt: OK


Let's Encrypt

O client του Let's Encrypt θέλει python 2.7

Σε CentOS 6 έχει by default python 2.6

Οπότε παρακάτω είναι μερικές