OpenSSL: Difference between revisions

From Lolly's Wiki
Jump to navigationJump to search
m (Text replacement - "<source" to "<syntaxhighlight")
Line 1: Line 1:
[[category:Security]]
[[category:Security]]
=Verify=
=Verify=
<source lang=bash>
<syntaxhighlight lang=bash>
# openssl verify -CAfile /srv/www/htdocs/pub/RHN-ORG-TRUSTED-SSL-CERT /etc/pki/spacewalk/jabberd/server.pem
# openssl verify -CAfile /srv/www/htdocs/pub/RHN-ORG-TRUSTED-SSL-CERT /etc/pki/spacewalk/jabberd/server.pem
</source>
</source>
<source lang=bash>
<syntaxhighlight lang=bash>
# openssl crl2pkcs7 -nocrl -certfile /srv/www/htdocs/pub/RHN-ORG-TRUSTED-SSL-CERT | openssl pkcs7 -print_certs -noout -print_certs  
# openssl crl2pkcs7 -nocrl -certfile /srv/www/htdocs/pub/RHN-ORG-TRUSTED-SSL-CERT | openssl pkcs7 -print_certs -noout -print_certs  
</source>
</source>
Line 12: Line 12:
=CSR=
=CSR=
== Create key and CSR ==
== Create key and CSR ==
<source lang=bash>
<syntaxhighlight lang=bash>
$ subject_without_cn='/C=DE/ST=Hamburg/L=Hamburg/O=Organisation/OU=Team'
$ subject_without_cn='/C=DE/ST=Hamburg/L=Hamburg/O=Organisation/OU=Team'
$ emailAddress='webadmin@server.de'
$ emailAddress='webadmin@server.de'
Line 20: Line 20:


== Verify your CSR==
== Verify your CSR==
<source lang=bash>
<syntaxhighlight lang=bash>
$ openssl req -text -noout -verify -in ${hosts[0]}-csr.pem
$ openssl req -text -noout -verify -in ${hosts[0]}-csr.pem
</source>
</source>

Revision as of 15:28, 25 November 2021

Verify

<syntaxhighlight lang=bash>

  1. openssl verify -CAfile /srv/www/htdocs/pub/RHN-ORG-TRUSTED-SSL-CERT /etc/pki/spacewalk/jabberd/server.pem

</source> <syntaxhighlight lang=bash>

  1. openssl crl2pkcs7 -nocrl -certfile /srv/www/htdocs/pub/RHN-ORG-TRUSTED-SSL-CERT | openssl pkcs7 -print_certs -noout -print_certs

</source>


CSR

Create key and CSR

<syntaxhighlight lang=bash> $ subject_without_cn='/C=DE/ST=Hamburg/L=Hamburg/O=Organisation/OU=Team' $ emailAddress='webadmin@server.de' $ declare -a hosts=( "name1.server.de" "name2.server.de" ) $ openssl req -newkey rsa:4096 -sha256 -keyout ${hosts[0]}-key.pem -out ${hosts[0]}-csr.pem -batch -subj "${subject_without_cn}/CN=${hosts[0]}/emailAddress=${emailAddress}" -reqexts SAN -config <(cat /etc/ssl/openssl.cnf <(printf "[SAN]\nsubjectAltName=DNS:${hosts[0]}${hosts[1]:+,DNS:${hosts[1]}}${hosts[2]:+,DNS:${hosts[2]}}${hosts[3]:+,DNS:${hosts[3]}}${hosts[4]:+,DNS:${hosts[4]}}")) </source>

Verify your CSR

<syntaxhighlight lang=bash> $ openssl req -text -noout -verify -in ${hosts[0]}-csr.pem </source>