tuto:linux:openssl
Ceci est une ancienne révision du document !
Table des matières
Openssl
Générer un certitifcat auto-signé
openssl genrsa -des3 -out server.key 2048 openssl req -new -key server.key -out server.csr openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Tester que le .key est bien associé au .crt
openssl x509 -noout -modulus -in <file>.crt | openssl md5 openssl rsa -noout -modulus -in <file>.key | openssl md5
Si les 2 commandes ne génèrent pas le meme md5 c'est que le le .key n'est pas celui qui à servi pour générer le .crt.
Hash d'un certificat
$ openssl x509 -hash -in ssl/server.crt -noout deb1aaa8
Voir l'émetteur du certificat
$ openssl x509 -noout -issuer -subject -in google.crt -nameopt multiline issuer= countryName = US organizationName = Google Inc commonName = Google Internet Authority G2 subject= countryName = US stateOrProvinceName = California localityName = Mountain View organizationName = Google Inc commonName = google.com
Tester la validité d'un certificat (erreur si auto-signé)
openssl verify ssl/server.crt
$ openssl verify -CAfile ssl/ca.crt ssl/server.crt ssl/server.crt: OK
Lecture d'un fichier PEM
openssl x509 -noout -text -in <file>.crt
Lecture d'un fichier DER (binaire)
openssl x509 -noout -text -in nnn -inform DER
Fingerprint
openssl x509 -fingerprint -noout -in client.crt
Conversion
PEM to DER
openssl x509 -in input.crt -inform PEM –out output.crt -outform DER
openssl rsa -in input.key -inform PEM -out output.key -outform DER
DER to PEM
openssl x509 -in input.crt -inform DER -out output.crt -outform PEM
openssl rsa -in input.key -inform DER -out output.key -outform PEM
Voir le certificat d'un site distant
openssl s_client -showcerts -connect www.google.com:443 openssl s_client -port 443 -host www.google.com
Connexion sur port SSL
openssl s_client -connect 127.0.0.1:9999
Crypter / signer un fichier
signer
openssl smime -sign -in message -out signed-message \ -signer /path/to/your/certificate.pem \ -inkey /path/to/your/secret-key.pem -text
crypter
openssl smime -encrypt -out encrypted-signed-message \ -in signed-message /path/to/intended-operators/certificate.pem
Décrypter
openssl smime -decrypt -in encrypted-signed-message \ -out received-msg \ -recip /path/to/operators/certificate.pem \ -inkey /path/to/operators/private-key.pem
Vérifier la signature
openssl smime -verify -text -CApath /global/globus/share/certificates \ -in received-msg
tuto/linux/openssl.1392494272.txt.gz · Dernière modification : 2014/02/15 19:57 de root