CERTIFICAT - Scorpa69/Scorpa69.github.io GitHub Wiki

PFX to CRT and KEY

Extract key crypted from pfx

openssl pkcs12 -in yourfilename.pfx -nocerts -out keyfilename-encrypted.key

Extract crt from pfx

openssl pkcs12 -in yourfilename.pfx -clcerts -nokeys -out certificatename.crt

Extrat key uncrypted from key crypted

openssl rsa -in keyfilename-encrypted.key -out keyfilename-decrypted.key

Création d'un certificat autosigné

Création du fichier de config CNF :

[ req ]
default_bits = 2048
default_md = sha256
default_keyfile = nom_serveur.key
encrypt_key = no
prompt = no
distinguished_name = req_distinguished_name
req_extensions = req_ext
prompt = no
[ req_distinguished_name ]
countryName = CODE_PAYS
stateOrProvinceName = Région
localityName = Ville
organizationName = Nom entreprise
commonName = fqdn_serveur
[ req_ext ]
subjectAltName = @alt_names
[alt_names]
DNS.1 = nom_serveur1
DNS.2 = nom_serveur2

Création du CSR et de la clé :

openssl.exe  req -new -sha256 -nodes -out nom_serveur.csr -newkey rsa:2048 -keyout nom_serveur.key -config nom_serveur.cnf

Création du certificat autosigné avec la clé et le CSR :

openssl x509 -req -days 10000 -in nom_serveur.csr -signkey nom_serveur.key -out nom_serveur.crt

Création d'un certificat signé par une CA d'entreprise Windows

Création du fichier de config CNF :

[ req ]
default_bits = 2048
default_md = sha256
default_keyfile = vdcszab02-dev.key
encrypt_key = no
prompt = no
distinguished_name = req_distinguished_name
req_extensions = req_ext
prompt = no
[ req_distinguished_name ]
countryName = FR
stateOrProvinceName = Ile de France
localityName = Paris
organizationName = Absys Cyborg
commonName = vdcszab02-dev.cyborg.dom
[ req_ext ]
subjectAltName = @alt_names
[alt_names]
DNS.1 = vdcszab02-dev
DNS.2 = zabsupdev.cyborg.dom
DNS.3 = zabsupdev
DNS.4 = web
DNS.5 = web.zbx.loc

Création du CSR pour le soumettre à la CA Windows

openssl req -config vdcszab02-dev.cnf -new -out vdcszab02-dev.csr

Divers :

Retrouver les nom de la CA : 

certutil -config - -ping

Liste Modèles certificats d'une CA d'entreprise windows :

certutil -config vdcsacs01.cyborg.dom\SIDFDC01 –catemplates > templates.txt

OU (-config CAHostName\CAName)

certutil -config vdcsacs01.cyborg.dom\SIDFDC01 –catemplates

Création d'une CA local pour signer des certificats

A FAIRE https://www.linuxtricks.fr/wiki/openssl-creation-de-certificats-et-ca-autosignes