![]()
I) Introduction :
Pourquoi créer une PKI ou IGC ?
Car un jour ou l’autre vous en aurez besoin, pour gèrer les certificats de vos clients (postes, utilisateurs, etc…).
Mon idée est de créer un certificats « utilisateurs » avec un nom de machine « CN : common name » permettant à un utilisateur de configurer son authentification par présentation de ce certificat (cela sera le sujet d’un autre petit tuto).
II) Installation :
Nous avons besoin juste de « openssl »… A nous de jouer !
# apt-get install openssl
III) Création de l’IGC :
Nous allons créer un répertoire dans /etc (car si vous faites des sauvegardes, /etc doit surement l’être).
# mkdir /etc/IGC
Nous nous plaçons dans ce répertoire !
# cd /etc/IGC
a) Création de l’autorité de certification :
Nous devons utiliser le script perl CA.pl, repérons le il n’est à priori pas dans le $PATH !
# locate CA.pl /usr/lib/ssl/misc/CA.pl <<--- nous l'avons repèré /usr/share/doc/openssl/doc/apps/CA.pl.pod.gz /usr/share/man/fr/man1/CA.pl.1SSL.gz /usr/share/man/man1/CA.pl.1ssl.gz
# /usr/lib/ssl/misc/CA.pl -newca
CA certificate filename (or enter to create)
Making CA certificate ...
Generating a 1024 bit RSA private key
.......++++++
...............................++++++
writing new private key to './demoCA/private/cakey.pem' <<--- repérez l'emplacement
Enter PEM pass phrase:unmotdepasse
Verifying - Enter PEM pass phrase:unmotdepasse
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:FR
State or Province Name (full name) [Some-State]:France
Locality Name (eg, city) []:Lyon
Organization Name (eg, company) [Internet Widgits Pty Ltd]:SLN
Organizational Unit Name (eg, section) []:SLN
Common Name (eg, YOUR name) []:Votre Nom
Email Address []:votreadresse@fai.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:SLN
Using configuration from /usr/lib/ssl/openssl.cnf
Enter pass phrase for ./demoCA/private/cakey.pem:
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number:
cb:01:75:c4:61:37:ab:d8
Validity
Not Before: Feb 20 05:16:54 2009 GMT
Not After : Feb 20 05:16:54 2012 GMT
Subject:
countryName = FR
stateOrProvinceName = France
organizationName = SLN
organizationalUnitName = SLN
commonName = Votre Nom
emailAddress = votreadresse@fai.com
X509v3 extensions:
X509v3 Subject Key Identifier:
37:AB:CD:5D:B6:0D:F8:8D:DB:A4:4D:F8:D1:04:23:E7:D2:01:56:17
X509v3 Authority Key Identifier:
keyid:37:AB:CD:5D:B6:0D:F8:8D:DB:A4:4D:F8:D1:04:23:E7:D2:01:56:17
DirName:/C=FR/ST=France/O=SLN/OU=SLN/CN=Votre Nom/emailAddress=votreadresse@fai.com
serial:CB:01:75:C4:61:37:AB:D8
X509v3 Basic Constraints:
CA:TRUE
Certificate is to be certified until Feb 20 05:16:54 2012 GMT (1095 days)
Write out database with 1 new entries
Data Base Updated
c) Création du certificat
Nous utilisons le même script perl, mais avec l’option nouvelle requête !
Je tiens aussi à vous informer de l’existence de TinyCA qui permet de tenir une petite IGC…
Création de la requête : # /usr/lib/ssl/misc/CA.pl -newreq
Generating a 1024 bit RSA private key
..........++++++
................++++++
writing new private key to 'newkey.pem'
Enter PEM pass phrase:unautremotdepasse
Verifying - Enter PEM pass phrase:unautremotdepasse -----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:FR
State or Province Name (full name) [Some-State]:France
Locality Name (eg, city) []:Marseille
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Team
Organizational Unit Name (eg, section) []:Team
Common Name (eg, YOUR name) []:nomdemachine
Email Address []:resp@team.fr
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:Team
Request is in newreq.pem, private key is in newkey.pem
c) On signe le certificat :
# /usr/lib/ssl/misc/CA.pl -sign
Using configuration from /usr/lib/ssl/openssl.cnf
Enter pass phrase for ./demoCA/private/cakey.pem:
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number:
cb:01:75:c4:61:37:ab:d9
Validity
Not Before: Feb 20 11:48:12 2009 GMT
Not After : Feb 20 11:48:12 2010 GMT
Subject:
countryName = FR
stateOrProvinceName = France
localityName = Marseille
organizationName = Team
organizationalUnitName = Team
commonName = nomdemachine
emailAddress = resp@team.fr
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
D3:CC:0D:23:66:8B:F5:69:20:84:B1:0E:CA:9B:D5:D5:CA:03:F7:27
X509v3 Authority Key Identifier:
keyid:37:AB:CD:5D:B6:0D:F8:8D:DB:A4:4D:F8:D1:04:23:E7:D2:01:56:17
Certificate is to be certified until Feb 20 11:48:12 2010 GMT (365 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
Signed certificate is in newcert.pem
d) Exportation du certificat au format pkcs
# openssl pkcs12 -export -out satellite.p12 -inkey newkey.pem -in newcert.pem
Enter pass phrase for newkey.pem:
Enter Export Password:
Verifying – Enter Export Password:
IV) Résumé :
Quatre commandes :
Une pour créer une autorité (cela sera fait qu’une seule fois).
Trois autres qui seront mises en œuvre à chaque nouveau certificat.
# /usr/lib/ssl/misc/CA.pl -newca # /usr/lib/ssl/misc/CA.pl -newreq # /usr/lib/ssl/misc/CA.pl -sign # openssl pkcs12 -export -out nomducertificat.p12 -inkey newkey.pem -in newcert.pem
Simple, non ?
Alors pourquoi s’embêter presque autant, pour si peu…? Là aussi cela ne saurait pas tarder… Autoriser les machines, les utilisateurs à s’identifier par leurs certificats !
Ah ben, voilà, c’est cela qu’il fallait nous dire !
Vous devinez peut-être que le prochain tuto court sera :
Authentification Radius pour Wifi par certificats !
Mon idée est de créer un certificats « utilisateurs » avec un nom de machine « CN : common name » permettant à un utilisateur de configurer son authentification par présentation de ce certificat (cela sera le sujet d’un autre petit tuto).
Voir : Authentification Radius par certificats
- Fin -


0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.