Blame
|
1 | #### Request clef + csr : |
||||||
| 2 | ||||||||
| 3 | ```bash |
|||||||
| 4 | openssl req -new -newkey rsa:2048 -keyout XXX.key -out XXX.csr |
|||||||
| 5 | ``` |
|||||||
| 6 | ||||||||
| 7 | #### Clef privée déchiffrée : |
|||||||
| 8 | ||||||||
| 9 | ```bash |
|||||||
| 10 | openssl rsa -in XXX.key -out XXX.unsecure.key |
|||||||
| 11 | ``` |
|||||||
| 12 | ||||||||
| 13 | #### Chiffrer une clef privée : |
|||||||
| 14 | ||||||||
| 15 | ```bash |
|||||||
| 16 | openssl rsa -in maCle.pem -des3 -out maCle.pem |
|||||||
| 17 | ``` |
|||||||
| 18 | ||||||||
| 19 | #### Construire un pfx/pkcs12 : |
|||||||
| 20 | ||||||||
| 21 | ```bash |
|||||||
| 22 | openssl pkcs12 -inkey privkey.pem -in chaine.pem -export -out fichier.pfx |
|||||||
| 23 | ``` |
|||||||
| 24 | ||||||||
| 25 | #### Utiliser le paramètre "Legacy" avec des vieux OS Windows : |
|||||||
| 26 | ||||||||
| 27 | ```bash |
|||||||
| 28 | openssl pkcs12 -in <PKCS#12 Filename> -legacy -out <Encrypted PEM Filename> |
|||||||
| 29 | openssl pkcs12 -keypbe PBE-SHA1-3DES -certpbe PBE-SHA1-3DES -export -in <Encrypted PEM Filename> -out <PKCS#12 Filename> -legacy -name "<Display Name>" |
|||||||
| 30 | ``` |
|||||||
| 31 | ||||||||
| 32 | #### Connexion direct d’un client TLS : |
|||||||
| 33 | ||||||||
| 34 | ```bash |
|||||||
| 35 | openssl s_client -connect address.of.my.isp.com:587 -starttls smtp |
|||||||
| 36 | ``` |
|||||||
| 37 | ||||||||
| 38 | #### Connexion avec une clef privée : |
|||||||
| 39 | ||||||||
| 40 | ```bash |
|||||||
| 41 | ssh -i clef.txt root@host |
|||||||
| 42 | ``` |
|||||||
| 43 | ||||||||
| 44 | #### Générer un id\_rsa.pub à partir d'une clef privée : |
|||||||
| 45 | ||||||||
| 46 | ```bash |
|||||||
| 47 | ssh-keygen -y -f ~/.ssh/clef-privée > ~/.ssh/id_rsa.pub |
|||||||
| 48 | # output d'une clef privée |
|||||||
| 49 | ssh-keygen -l -f ~/.ssh/id_rsa |
|||||||
| 50 | ``` |
|||||||
| 51 | ||||||||
| 52 | #### Afficher le contenu d'un certificat .pem X509 : |
|||||||
| 53 | ||||||||
| 54 | ```bash |
|||||||
| 55 | openssl x509 -in <fichier.pem> -noout -text | grep DNS |
|||||||
| 56 | ``` |
|||||||
| 57 | ||||||||
| 58 | #### Vérifier une chaine de certif : |
|||||||
| 59 | ||||||||
| 60 | ```bash |
|||||||
| 61 | openssl verify -CAfile chaine.pem cert.pem |
|||||||
| 62 | ``` |
|||||||
| 63 | ||||||||
| 64 | #### Output d'un certificat SSL : |
|||||||
| 65 | ||||||||
| 66 | ```bash |
|||||||
| 67 | openssl x509 -in cert.pem -text -noout |
|||||||
| 68 | ``` |
|||||||
| 69 | ||||||||
| 70 | #### Générer une mini CA et l'utiliser pour créer des certifs (serveur/client) |
|||||||
| 71 | ||||||||
| 72 | ```bash |
|||||||
| 73 | # CREATION DE LA CA ET SON CERTIF ASSOCIE : |
|||||||
| 74 | openssl genrsa -out ca-key.pem 4096 |
|||||||
| 75 | openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem |
|||||||
| 76 | # dans les réponse de la commande :common name : test-server.home.naoned.net |
|||||||
| 77 | ||||||||
| 78 | # CREATION DU CERTIFICAT SERVEUR : |
|||||||
| 79 | openssl genrsa -out server-key.pem 4096 |
|||||||
| 80 | openssl req -subj "/CN=test-server.home.naoned.net" -sha256 -new -key server-key.pem -out server.csr |
|||||||
| 81 | # créer un request CERTIF pour le nom du serveur ainsi que les fonctions d'auth étendue |
|||||||
| 82 | echo "subjectAltName = DNS:test-server.home.naoned.net,IP:172.16.16.x;IP:127.0.0.1" >>extFile.cnf |
|||||||
| 83 | echo "extendedKeyUsage = serverAuth" >>extfile.cnf |
|||||||
| 84 | openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem -extfile extfile.cnf |
|||||||
| 85 | # ok le certificat du serveur est créé et validé via la CA ainsi qu'avec l'extension "serverAuth" |
|||||||
| 86 | # on fait la même chose pour le client qui se connectera |
|||||||
| 87 | openssl genrsa -out key.pem 4096 |
|||||||
| 88 | openssl req -subj "/CN=client" -new -key key.pem -out client.csr |
|||||||
| 89 | echo "extendedKeyUsage = clientAuth" >>extfile-client.cnf |
|||||||
| 90 | openssl x509 -req -days 365 -sha256 -in client.csr -CA ca.pem -CAkey ca-key.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -extfile extfile-client.cnf |
|||||||
| 91 | ``` |
|||||||
