View source for openssl

{{anchor href="top"}}

Hits :  **{{hits}}**

Last Edit: 26.03.2020 17:40  
Last Edit: 20.03.2016 22:02

== OpenSSL :: Tips ==

{{ToC from="h2" to="h3"}}

==== Private Key ====

%%(bash)

$ openssl rsa -in privateKey.key -check

$ openssl rsa -in privateKey.key -text  | more

%%

==== Verify  Key Vs Crt ====

%%(bash)

$ openssl rsa -noout -modulus -in priv.key | md5sum
7fadd5006a36cae62a437292e52d40db -

$ openssl x509 -noout -modulus -in pub.crt | md5sum 
7fadd5006a36cae62a437292e52d40db  -
%%


----

View expiration date on a SSL cert:

%%(bash)
$ openssl x509 -in <(openssl s_client -connect google.com:443) -noout -enddate

$ openssl x509 -in <(openssl s_client -connect balaskas.gr:443 2>/dev/null) -noout -enddate 


%%

=== TLS ===

if  [ Protocol==TLSv1.2 ] then

%%(bash)
$ openssl s_client -connect example.com:443 -tls1_2 -tlsextdebug 2>&1 | grep extension
%%


%%(bash)
$ openssl s_client -starttls smtp -crlf -connect localhost:25 | openssl x509 -noout -dates 
%%


%%(bash)
$ openssl s_client -connect smtp.gmail.com:587 -starttls smtp < /dev/null
%%


=== x509 ===

%%(bash)

$ openssl x509 -text -noout -in <(openssl s_client -connect google.com:443)

%%

%%(bash)
$ openssl req -text -noout -verify -in CSR.csr
%%



==== Expiration === 

%%(bash)
$ export CN='balaskas.gr';
$ openssl x509 -text -in <(openssl s_client -connect ${CN}:443) | grep -E 'Not Before|Not After'
%%

=== xmpp / jabber ===

==== server ====

%%(bash)
$ openssl s_client -connect balaskas.gr:5269  -starttls xmpp < /dev/null
%%

==== client ====

%%(bash)
$ openssl s_client -showcerts -connect balaskas.gr:5222 -starttls xmpp  </dev/null
%%




=== imap ===

==== imaps ===

%%(bash)

$ openssl s_client -showcerts -connect imap.balaskas.gr:993 -crlf < /dev/null

%%


==== starttls ====


%%(bash)

$ openssl s_client -showcerts -connect imap.balaskas.gr:143 -starttls imap </dev/null

%%


=== SMTP ===

==== SMTPS ====

%%(bash)

$ openssl s_client -showcerts -connect balaskas.gr:587 -starttls smtp </dev/null 


%%

==== smtps ==== 

%%(bash)
$ openssl s_client -showcerts -connect balaskas.gr:465 </dev/null | head

%%

==== TTLS ====

%%(bash)

$ openssl s_client -showcerts -connect balaskas.gr:25 -starttls smtp </dev/null 

%%


=== Convert p7b to x509 ===

%%(bash)

$ openssl pkcs7 -print_certs -in example.org.p7b -out example.org.crt

%%


=== Verify Chain ===

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


=== DoT ===

%%(bash)
$ openssl x509 -in <(openssl s_client -connect dot.libredns.gr:853 2>/dev/null) -noout -enddate 
%%