<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Void And Any &#187; SSL</title>
	<atom:link href="http://voidandany.free.fr/index.php/tag/ssl/feed/" rel="self" type="application/rss+xml" />
	<link>http://voidandany.free.fr</link>
	<description>mon bazar...</description>
	<lastBuildDate>Sat, 09 Dec 2017 09:24:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Sécurisation NGINX : mise en oeuvre de connexions https</title>
		<link>http://voidandany.free.fr/index.php/securisation-nginx-mise-en-oeuvre-de-connexions-https/</link>
		<comments>http://voidandany.free.fr/index.php/securisation-nginx-mise-en-oeuvre-de-connexions-https/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 14:53:38 +0000</pubDate>
		<dc:creator>voidAndAny</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://voidandany.free.fr/?p=3678</guid>
		<description><![CDATA[Mon serveur web NGINX ne sert que du contenu privé protégé par mot de passe, mais si l&#8217;accès à ce contenu est protégé, les données qui transitent sur le réseau elles ne le sont pas. Pour cela il faut mettre &#8230; <a href="http://voidandany.free.fr/index.php/securisation-nginx-mise-en-oeuvre-de-connexions-https/">Continuer la lecture <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Mon serveur web NGINX ne sert que du <a title="Restreindre l’accès d’un site, d’un répertoire avec Nginx" href="../index.php/restreindre-lacces-dun-site-dun-repertoire-avec-nginx/">contenu privé protégé par mot de passe</a>, mais si l&#8217;accès à ce contenu est protégé, les données qui transitent sur le réseau elles ne le sont pas.</p>
<p>Pour cela il faut mettre en œuvre un chiffrage via <a href="http://fr.wikipedia.org/wiki/Hypertext_Transfer_Protocol#HTTPS">https</a>.</p>
<p>Https se base sur un <a href="http://fr.wikipedia.org/wiki/Transport_Layer_Security" target="_blank">système de clé de cryptage publique/certificat</a>, il existe plusieurs moyen pour obtenir ces fichiers :</p>
<ul>
<li>Acheter le certificat auprès d&#8217;un organisme reconnu, peut être très cher, exemple : <a href="http://www.thawte.fr/products/index.html">600€ pour 2 ans</a> ou moins cher : <a href="http://www.godaddy.com/ssl/ssl-certificates.aspx?ci=8979">Go Daddy</a>)</li>
<li>Avoir le certificat gratuit avec votre nom de domaine (<a href="http://www.gandi.net/ssl">chez Gandi par exemple pour 1 an</a>)</li>
<li>Avoir un certificat gratuit avec un organisme <a href="http://wiki.cacert.org/InclusionStatus" target="_blank">presque reconnu</a> comme <a href="http://www.cacert.org/" target="_blank">CAcert </a></li>
<li>Générer un certificat (certificat auto-signé)</li>
</ul>
<p>J&#8217;ai personnellement choisi cette dernière solution.</p>
<p>Dans mon article <a title="Lien permanent vers OpenSSL puissance et complexité" rel="bookmark" href="../index.php/openssl-puissance-et-complexite/">OpenSSL puissance et complexité</a>, j&#8217;ai listé/référencé les étapes et commandes openssl disponible pour créer un certificat.</p>
<p>&nbsp;</p>
<p>Voici les sujets abordé par cet article :</p>
<ul>
<li><a href="#para1">Gestion des certificats manuellement</a></li>
<li><a href="#para2">Gestion des certificats avec easyCA</a></li>
<li><a href="#para3">Configuration NGINX</a></li>
<li><a href="#para3">Configuration Firefox</a></li>
</ul>
<p>&nbsp;</p>
<h2><a name="para1"></a>Gestion des certificats manuellement</h2>
<h3>Préparation de l&#8217;environnement</h3>
<p>Je vais créer un répertoire myCa dans le /home de mon utilisateur et y placer tout ce qui sera nécessaire à gérer les certificats</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> myCA<span style="color: #000000; font-weight: bold;">/</span>certs <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> myCA<span style="color: #000000; font-weight: bold;">/</span>private <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> myCA<span style="color: #000000; font-weight: bold;">/</span>csr <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> myCA<span style="color: #000000; font-weight: bold;">/</span>newcerts <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> myCA<span style="color: #000000; font-weight: bold;">/</span>crl <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> myCA<span style="color: #000000; font-weight: bold;">/</span>tmp <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">cd</span> myCA
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'01'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> serial  <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">touch</span> index.txt
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>openssl.cnf .</pre></div></div>

<h3>Configuration d&#8217;openSSL</h3>
<p>On édite ensuite le fichier openssl.cnf copié dans notre répertoire myCA, pour modifier les éléments suivants :</p>
<p>Section [ CA_default ] on paramètre les dossiers, seul la première valeur est à modifier :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">dir</span>        = <span style="color: #000000; font-weight: bold;">&lt;</span>strong<span style="color: #000000; font-weight: bold;">&gt;/</span>home<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>utilisateur<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">/</span>myCA<span style="color: #000000; font-weight: bold;">&lt;/</span>strong<span style="color: #000000; font-weight: bold;">&gt;</span>            <span style="color: #666666; font-style: italic;"># Where everything is kept</span>
certs        = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>certs        <span style="color: #666666; font-style: italic;"># Where the issued certs are kept</span>
crl_dir        = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>crl        <span style="color: #666666; font-style: italic;"># Where the issued crl are kept</span>
database    = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>index.txt    <span style="color: #666666; font-style: italic;"># database index file.</span>
new_certs_dir    = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>newcerts        <span style="color: #666666; font-style: italic;"># default place for new certs.</span>
certificate    = <span style="color: #007800;">$certs</span><span style="color: #000000; font-weight: bold;">/</span>cacert.pem    <span style="color: #666666; font-style: italic;"># The CA certificate</span>
serial        = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>serial         <span style="color: #666666; font-style: italic;"># The current serial number</span>
crl        = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>crl.pem         <span style="color: #666666; font-style: italic;"># The current CRL</span>
private_key    = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>cakey.pem <span style="color: #666666; font-style: italic;"># The private key</span>
RANDFILE    = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>.rand    <span style="color: #666666; font-style: italic;"># private random number file</span></pre></div></div>

<p>Un peu plus loin dans cette même section, on paramètre la duré de validité par défaut des certificats et le cryptage utilisé :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">default_days    = 1825            # how long to certify for
default_crl_days= 30            # how long before next CRL
default_md    = sha1            # which md to use.</pre></div></div>

<p>Dans la section [ req_distinguished_name ] j&#8217;ai francisé les libellé et adpater les valeurs par défaut :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[ req_distinguished_name ]
 countryName                     = Pays (2 lettres)
 countryName_default             = FR
 countryName_min                 = 2
 countryName_max                 = 2
 stateOrProvinceName             = Region
 stateOrProvinceName_default     = PAYS DE LOIRE
 localityName                    = Ville
 localityName_default            = Nantes
 0.organizationName              = Societe
 0.organizationName_default      = VoidAndAny
 #organizationalUnitName         = Organizational Unit Name (eg, section)
 #organizationalUnitName_default =
 commonName                      = Site
 commonName_max                  = 64
 emailAddress                    = Email
 emailAddress_max                = 64
 emailAddress_default            = mon_email@free.fr</pre></div></div>

<p>Dès lors les questions sont les suivantes et il suffit de les valider par entrée pour avoir les valeurs par défaut (optionnel) :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Pays (2 lettres) [FR]:
Region [PAYS DE LOIRE]:
Ville [Nantes]:
Societe [VoidAndAny]:
Site []: mon_domaine.fr
Email [mon_email@free.fr]:</pre></div></div>

<p>Dans la section [ usr_cert ] j&#8217;ai modifié les commentaire qui seront embarqués dans les certificats :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">nsComment            = &quot;Void And Any Generated Certificate&quot;</pre></div></div>

<h3>Création de l&#8217;autorité de certification</h3>
<p>On va tout d&#8217;abord créer notre autorité de certification qui permettra de signer les certificats serveurs suivant.</p>
<p>Cela se fait avec la commande (se placer dans le répertoire myCA) :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-x509</span> <span style="color: #660033;">-config</span> .<span style="color: #000000; font-weight: bold;">/</span>openssl.cnf <span style="color: #660033;">-keyout</span> .<span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>cakey.pem <span style="color: #660033;">-out</span> .<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>cacert.pem <span style="color: #660033;">-days</span> <span style="color: #000000;">1825</span></pre></div></div>

<p>Lors de la génération du certificat un mot de passe vous est demandé, en choisir un robuste et ne pas l&#8217;oublier sous peine de ne plus pouvoir vous servir de votre autorisé de certification.</p>
<h3>Création du/des certificats</h3>
<p>En 2 temps, création de la clé et de la demande de certificat :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-keyout</span> .<span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>mondomaine.key <span style="color: #660033;">-out</span> .<span style="color: #000000; font-weight: bold;">/</span>csr<span style="color: #000000; font-weight: bold;">/</span>mondomaine.csr <span style="color: #660033;">-config</span> .<span style="color: #000000; font-weight: bold;">/</span>openssl.cnf <span style="color: #660033;">-nodes</span> <span style="color: #660033;">-days</span> <span style="color: #000000;">1825</span></pre></div></div>

<p>L’option -nodes permet d’indiquer que la clé qui doit être générée ne doit pas être protégée par un mot de passe (passphrase)</p>
<p>&nbsp;</p>
<p>La commande vous poseras quelques questions :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Generating a 2048 bit RSA private key
 .............+++
 ............................+++
 writing new private key to '/etc/nginx/certificates/test.key'
 -----
 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]:PAYS DE LOIRE
 Locality Name (eg, city) []:Nantes
 Organization Name (eg, company) [Internet Widgits Pty Ltd]:VoidAndAny
 Organizational Unit Name (eg, section) []:
 Common Name (eg, YOUR name) []:mon_domaine.fr
 Email Address []:mon_email@free.fr</pre></div></div>

<p>La zone la plus importante est &laquo;&nbsp;Common name&nbsp;&raquo; qui doit correspondre au nom du domaine/sous-domaine que vous voulez protéger.</p>
<p>&nbsp;</p>
<p>Création du certificat à partir de la demande de certificat et signature de ce dernier avec notre autorité de certification :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl ca <span style="color: #660033;">-infiles</span> .<span style="color: #000000; font-weight: bold;">/</span>csr<span style="color: #000000; font-weight: bold;">/</span>mondomaine.csr <span style="color: #660033;">-out</span> .<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>mondomaine.crt <span style="color: #660033;">-config</span> .<span style="color: #000000; font-weight: bold;">/</span>openssl.cnf</pre></div></div>

<p>Les certificat et sa clé sont alors respectivement dans les sous-répertoires certs et private.</p>
<p>&nbsp;</p>
<p>Voila pour la création manuelle voici comment automatiser tout cela et ne pas avoir de ligne de commande à taper.</p>
<p>&nbsp;</p>
<h2><a name="para2"></a>Gestion des certificats avec easyCA</h2>
<p>EasyCA est un script qui n&#8217;est plus maintenu depuis 2005 et que l&#8217;on peut retrouver <a title="esayca" href="http://sourceforge.net/projects/easyca" target="_blank">ICI</a>, personnellement j&#8217;ai utilisé la <a href="http://blog.guiguiabloc.fr/index.php/2008/12/02/pki-pki-oh-pki-pki-ah/">version modifiée de GuiguiAbloc</a> que l&#8217;on trouve <a href="http://guiguiabloc.appspot.com/wp-content/2008/12/easyca.tgz">ICI</a></p>
<p>Je vais comme précédemment faire du répertoire myCA de mon home le lieu de travail. (si vous avez fait des essais manuellement il peut être conseillé de tout supprimer le contenu du dit répertoire ou d&#8217;en utiliser un autre)</p>
<p>Télécharger l&#8217;archive, la décompresser et rendre le script exécutable :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> ~<span style="color: #000000; font-weight: bold;">/</span>myCA <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>myCA
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>guiguiabloc.appspot.com<span style="color: #000000; font-weight: bold;">/</span>wp-content<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2008</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">12</span><span style="color: #000000; font-weight: bold;">/</span>easyca.tgz
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvf</span> easyca.tgz
<span style="color: #c20cb9; font-weight: bold;">mv</span> easyca<span style="color: #000000; font-weight: bold;">/*</span> .
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</span> easyCA.sh</pre></div></div>

<p>Éditer le fichier openssl.cnf fournis, modifier les lignes préalablement décrites et supprimer la ligne :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># !!!!! remove this line after configuration as it is NOT_CONFIGURED yet !!!</pre></div></div>

<p><strong>Rque </strong>: j&#8217;ai en plus changé les différents paramètres nsComment en fin de fichier.</p>
<p>Lancer le script easyCA.sh, le menu suivant apparaît :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">=====================================================================
 Certificate Management System
 easyCA version 0.9(6) by Ferry Kemps and Guiguiabloc
 GPL Licensed
 =====================================================================
&nbsp;
 1) Sign a Certificate Signing Request (PKCS#10)
 2) Create a Server Certificate (PEM SelfSigned)
 3) Create a Client Certificate (PKCS#12)
 4) Create a Certificate Signing Request
 5) Generate Certificate Revocation List (CRL)
 6) List, Display and Revoke Certificates
&nbsp;
 I) Initialize Root Certificate Authority (CA)
 O) Initialize OCSP Server Certificate
 B) Backup &amp; Restore the Certificate environment
 R) Reinstall easyCA (erase)
&nbsp;
==&gt; Make your choice [none]:</pre></div></div>

<p>(dans les &laquo;&nbsp;copie d&#8217;écran&nbsp;&raquo; suivante je n&#8217;ai pas personnalisé mon openssl.cnf, d&#8217;où les localité, adresse mail par défaut)</p>
<h3>Création de l&#8217;autorité de certification</h3>
<p>Pour créer l&#8217;autorité de certification il suffit de choisir l&#8217;option I :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">-----------------------------------------------------------------------
 ----------------- Initialize root Certificate Authority ---------------
 -----------------------------------------------------------------------
&nbsp;
Are you sure you want to (re)initialize the Root CA? [y|n]: y
 &gt;&gt;&gt; Initializing Root CA &lt;&lt;&lt;
 Generating a 1024 bit RSA private key
 ...................++++++
 .............................................++++++
 writing new private key to './private/cakey.pem'
 Enter PEM pass phrase:
 Verifying - Enter PEM pass phrase:
 -----
 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) [NL]:
 State or Province Name (full name) [Gelderland]:
 Locality Name (eg, city) [Arnhem]:
 Organization Name (eg, company) [Your Company Name]:
 Organizational Unit Name (eg, section) [HQ]:
 Common Name (eg, your name or your server's hostname) []:
 Email Address [postmaster@domain.ext]:
&nbsp;
Press [enter] to continue</pre></div></div>

<p>Comme dans le paragraphe précédent il faut choisir une passphrase sécurisé et ne pas l&#8217;oublier. Le Common Name n&#8217;a que peut d&#8217;importance ici.</p>
<h3>Création du/des certificats</h3>
<p>Pour générer un certificat serveur, il faut procéder en 2 temps, la demande de certificat, option 4 du menu :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">-----------------------------------------------------------------------
 --------------- Generate Certificate Signing Request ------------------
 -----------------------------------------------------------------------
&nbsp;
Enter Certificate CN (Common name|FQDN) like www.example.com [none]: mondomaine
 Generating a 1024 bit RSA private key
 ..................++++++
 .......++++++
 writing new private key to './private/mondomaine-key.pem'
 -----
 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) [NL]:
 State or Province Name (full name) [Gelderland]:
 Locality Name (eg, city) [Arnhem]:
 Organization Name (eg, company) [Your Company Name]:
 Organizational Unit Name (eg, section) [HQ]:
 Common Name (eg, your name or your server's hostname) []:mondomaine.fr
 Email Address [postmaster@domain.ext]:
&nbsp;
Please enter the following 'extra' attributes
 to be sent with your certificate request
 A challenge password []:
 An optional company name []:
&nbsp;
Certificate Signing Request (CSR) stored as: ./csr/mondomaine.csr
 Certificate private-key stored as: ./private/mondomaine-key.pem
 Press [enter] to continue</pre></div></div>

<p>La première question (Enter Certificate CN (Common name|FQDN) like www.example.com [none]:) ne sert pas à alimenter le common name du certificat mais a déterminer le nom des fichier certificat et clé.</p>
<p>A la question common name, il faut ici indiquer le domaine sur lequel s&#8217;appliquera la certificat sous peine d&#8217;avoir des avertissement de sécurité dans les navigateurs.</p>
<p>&nbsp;</p>
<p>2ème étape obtenir le certificat et le signer , option 1 du menu :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">-----------------------------------------------------------------------
 --------------- Certifiace Signing Request handling -------------------
 -----------------------------------------------------------------------
&nbsp;
(CSR request files should be copied into directory: ./csr)
&nbsp;
1: mondomaine.csr
&nbsp;
==&gt; Select the CSR to sign [none]: 1
&nbsp;
==&gt; Add OCSP Extension to Certificate ? [y/N]: N
&nbsp;
==&gt; Select the Usage Key [server|client|none]: server
 Using configuration from ./openssl.cnf
 Enter pass phrase for ./private/cakey.pem:
 Check that the request matches the signature
 Signature ok
 Certificate Details:
 Serial Number: 1 (0x1)
&nbsp;
...
&nbsp;
 Certificate is to be certified until Jun 19 18:36:00 2016 GMT (1825 days)
 Sign the certificate? [y/n]:y
&nbsp;
1 out of 1 certificate requests certified, commit? [y/n]y
 Write out database with 1 new entries
 Data Base Updated
&nbsp;
Signed certificate stored as: ./certs/mondomaine.crt
 Return this certificate to the requesting party.
&nbsp;
Display Certificate? y/n [n] n</pre></div></div>

<p>On sélectionne les demande de certificat en cours (il peut y en avoir plusieurs), on indique le rôle du certificat à générer (server), on saisi le mot de passe de l&#8217;autorité de certification et voila&#8230;</p>
<p>L’utilisation de easyCA est quand même beaucoup plus simple que de se taper les lignes de commande&#8230;.</p>
<p>&nbsp;</p>
<p>Pour info voici les commandes par easyCA  qui sont lancées pour les 3 étapes décrites ci-dessus :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-x509</span> <span style="color: #660033;">-config</span> .<span style="color: #000000; font-weight: bold;">/</span>openssl.cnf <span style="color: #660033;">-keyout</span> .<span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>cakey.pem <span style="color: #660033;">-out</span> .<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>cacert.pem <span style="color: #660033;">-days</span> <span style="color: #000000;">1825</span>
&nbsp;
openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-nodes</span> <span style="color: #660033;">-config</span> .<span style="color: #000000; font-weight: bold;">/</span>openssl.cnf <span style="color: #660033;">-days</span> <span style="color: #000000;">1825</span> <span style="color: #660033;">-keyout</span> .<span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>mondomaine-key.pem <span style="color: #660033;">-out</span> .<span style="color: #000000; font-weight: bold;">/</span>csr<span style="color: #000000; font-weight: bold;">/</span>mondomaine.csr
&nbsp;
openssl ca <span style="color: #660033;">-config</span> .<span style="color: #000000; font-weight: bold;">/</span>openssl.cnf <span style="color: #660033;">-cert</span> .<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>cacert.pem <span style="color: #660033;">-extensions</span>  SERVEUR <span style="color: #660033;">-in</span> .<span style="color: #000000; font-weight: bold;">/</span>csr<span style="color: #000000; font-weight: bold;">/</span>mondomaine.csr <span style="color: #660033;">-out</span> .<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>mondomaine.crt</pre></div></div>

<p>Elle très très semblables à celles que j&#8217;ai décrite dans le premier paragraphe&#8230;</p>
<p><strong><br />
 </strong></p>
<h2><a name="para3"></a>Configuration NGINX</h2>
<p>Une fois un certificat généré pour votre site que ce soit manuellement ou via easyCA, il faut tout d&#8217;abord copier le clé et le dit certificat vers un répertoire qui sera accessible par NGINX.</p>
<p>Dans mon cas j&#8217;ai créé un répertoire certificates dans /etc/nginx.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> ~
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> myCA<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>mondomaine.crt <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>certificates
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> myCA<span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>mondomaine-key.pem <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>certificates
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> root.root <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>certificates<span style="color: #000000; font-weight: bold;">/</span>mondomaine-key.pem
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">400</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>certificates<span style="color: #000000; font-weight: bold;">/</span>mondomaine-key.pem</pre></div></div>

<p>Il suffit ensuite d&#8217;indiquer à NGINX pour le site voulu l&#8217;écouter sur le port 443 (au lieu du 80) et l&#8217;utilisation du certificat et de la clé privée</p>
<pre>server {
    listen               443;
    server_name          mondomaine.fr;

    ssl                  on;
    ssl_certificate      /etc/nginx/certificates/mondomaine.crt;
    ssl_certificate_key  /etc/nginx/certificates/mondomaine-key.fr;

....
  }</pre>
<p>Et rediriger le port 443 vers votre serveur&#8230;</p>
<p>&nbsp;</p>
<h2><a name="para4"></a>Configuration Firefox</h2>
<p>Lorsque vous irez sur votre site pour la première fois vous aurez un message d&#8217;avertissement car votre autorité de certification (c&#8217;est à dire votre serveur) n&#8217;est pas reconnue par le navigateur :</p>
<p><a href="http://voidandany.free.fr/wp-content/uploads/2011-06-22_161311.png"><img class="aligncenter size-full wp-image-4184" title="2011-06-22_161311" src="http://voidandany.free.fr/wp-content/uploads/2011-06-22_161311.png" alt="" width="641" height="324" /></a></p>
<p>Si on regarde les détail technique on a ceci :</p>
<p><a href="http://voidandany.free.fr/wp-content/uploads/2011-06-22_161320.png"><img class="aligncenter size-full wp-image-4185" title="2011-06-22_161320" src="http://voidandany.free.fr/wp-content/uploads/2011-06-22_161320.png" alt="" width="433" height="104" /></a>Ou ceci <a href="http://voidandany.free.fr/wp-content/uploads/Sélection_00512m.png"><img class="aligncenter size-full wp-image-4190" title="Sélection_00512m" src="http://voidandany.free.fr/wp-content/uploads/Sélection_00512m.png" alt="" width="408" height="152" /></a>Dans le premeir cas je ne comprend pas très bien l&#8217;erreur, peut être est ce d^au fait que j&#8217;utilise un certificat joker mais ceci est une autre histoire, dans le 2ème cas on a 2 erreurs, le fait que le certificat est auto-signée et le fait que le common name donnée lors de la création du certification ne correspond pas au domaine sur lequel il a été appliqué.</p>
<p>Dans tous les cas pour passer outre il suffit d&#8217;importer le certificat racine publique de notre autorité de certification.</p>
<p>Il faut donc diffuser, copier le fichier cacert.pem contenu dans le répertoire certs sur votre serveur sur les machine clientes. ATTENTION il ne faut surtout pas diffuser la clé privé cakey.pem</p>
<p>&nbsp;</p>
<p>Ensuite sur les machines clientes dans Firefox aller dans le menu &laquo;&nbsp;Avancé&nbsp;&raquo; sur l&#8217;onglet &laquo;&nbsp;Chiffrement&nbsp;&raquo; et cliquer sur &laquo;&nbsp;Afficher les certificats&nbsp;&raquo; :</p>
<p><a href="http://voidandany.free.fr/wp-content/uploads/2011-06-22_161336.png"><img class="aligncenter size-full wp-image-4186" title="2011-06-22_161336" src="http://voidandany.free.fr/wp-content/uploads/2011-06-22_161336.png" alt="" width="548" height="500" /></a>Dans l&#8217;onglet &laquo;&nbsp;Autorités&nbsp;&raquo; cliquer sur &laquo;&nbsp;Importer&#8230;&nbsp;&raquo; et sélectionner votre fichier (cacert.pem)</p>
<p>Sélectionner l&#8217;usage que vous souhaitez faire du certificat &laquo;&nbsp;identifier des sites web&nbsp;&raquo; :</p>
<p><a href="http://voidandany.free.fr/wp-content/uploads/2011-06-22_161410.png"><img class="aligncenter size-full wp-image-4188" title="2011-06-22_161410" src="http://voidandany.free.fr/wp-content/uploads/2011-06-22_161410.png" alt="" width="515" height="291" /></a></p>
<p>Votre autorité de certification est désormais reconnue :</p>
<p><a href="http://voidandany.free.fr/wp-content/uploads/2011-06-22_161503.png"><img class="aligncenter size-full wp-image-4183" title="2011-06-22_161503" src="http://voidandany.free.fr/wp-content/uploads/2011-06-22_161503.png" alt="" width="586" height="165" /></a></p>
<p>Et la page devrait s&#8217;afficher sans problème.</p>
<p>&nbsp;</p>
<p>Dans IE il faut aller dans Option Internet &gt; Onglet Contenu &gt; Bouton Certificats, puis onglet Autorités principales de confiance &gt; Bouton Importer</p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><em><strong>Sources : </strong></em></span></p>
<p>Gestion des certificats : <span style="text-decoration: underline;"><em><strong><br />
 </strong></em></span></p>
<ul>
<li><a title="Be your own Certificate Authority (CA)" rel="bookmark" href="http://www.g-loaded.eu/2005/11/10/be-your-own-ca/">Be your own Certificate Authority (CA)</a></li>
<li><a href="http://artisan.karma-lab.net/creer-sa-propre-mini-pki">Créer sa propre (mini) PKI</a> : un article très très clair (comme tous les articles de ce site) sur les certificats, il devrait être obligatoire de le lire (malheureusement pour moi je ne l&#8217;ai trouvé que tard)</li>
<li><a href="http://blog.guiguiabloc.fr/index.php/2008/12/02/pki-pki-oh-pki-pki-ah/">PKI, PKI, oh ! PKI, PKI, ah !</a></li>
</ul>
<p>Configuration NGINX :</p>
<ul>
<li><a rel="next" href="http://blog.shk-desktop.com/565-nginx-serveur-web-complet-bluffant">nginx: serveur web complet bluffant</a></li>
<li><a title="Nginx , SSL et plus encore .." href="http://lindev.fr/index.php?post/2010/04/06/Ngins-%2C-SSL-et-plus-encore-..">Nginx , SSL et plus encore ..</a></li>
</ul>
<p>Autre :</p>
<ul>
<li><a href="http://www.tux-planet.fr/verifier-automatiquement-lexpiration-de-certificats-ssl/">Vérifier automatiquement l&#8217;expiration de certificats SSL &#8211; Tux-planet</a></li>
<li><a href="http://www.informathic.com/post/2010/12/24/installer-ssl-gandi-nginx">Installer un certificat Gandi SSL Standard sur Nginx</a></li>
</ul>
<ul>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://voidandany.free.fr/index.php/securisation-nginx-mise-en-oeuvre-de-connexions-https/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>OpenSSL puissance et complexité</title>
		<link>http://voidandany.free.fr/index.php/openssl-puissance-et-complexite/</link>
		<comments>http://voidandany.free.fr/index.php/openssl-puissance-et-complexite/#comments</comments>
		<pubDate>Wed, 01 Jun 2011 11:33:52 +0000</pubDate>
		<dc:creator>voidAndAny</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://voidandany.free.fr/?p=3947</guid>
		<description><![CDATA[Dans le but de mettre une connexion https sur certains de mes sites NGINX je me suis intéressé à la génération du certificat et de la clé nécessaire pour cette opération. Au fil de mes lectures j&#8217;ai pu constater la &#8230; <a href="http://voidandany.free.fr/index.php/openssl-puissance-et-complexite/">Continuer la lecture <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/epitti/2585357353/"><img class="size-full wp-image-3981 alignleft" title="Enigma" src="http://voidandany.free.fr/wp-content/uploads/2585357353_9974cf0559_m.jpg" alt="" width="240" height="180" /></a>Dans le but de mettre une <strong>connexion https</strong> sur certains de mes sites NGINX je me suis intéressé à la génération du certificat et de la clé nécessaire pour cette opération.</p>
<p>Au fil de mes lectures j&#8217;ai pu constater la puissance de la <strong>commande openssl </strong>permettant de générer ces fichiers mais aussi la difficulté à en appréhender le fonctionnement.</p>
<p>En effet pour réaliser une même tache il est possible de lancer x commandes différentes avec y options différentes.</p>
<p>De même pour passer un site en https, certains décrivent la création d&#8217;une clé et d&#8217;un certificat auto-signé directement utilisé par le serveur web et d&#8217;autres créent d&#8217;abord une autorité de certification (sous la forme d&#8217;une clé et d&#8217;un certificat auto-signé) qu&#8217;ils utilisent ensuite pour signer un autre certificat qui lui sera paramétré dans le serveur Web.</p>
<p>Ci-dessous les 3 types d&#8217;opérations trouvés :</p>
<ul>
<li>Génération d&#8217;un certificat serveur auto-signé (et de sa clé) pour utilisation directe par le serveur web.</li>
<li>Création d&#8217;une autorité de certification </li>
<li>Génération d&#8217;un certificat serveur et signature de ce dernier pour une autorité de certification </li>
</ul>
<p>Pour chacune des ces opérations j&#8217;ai listés (non exhaustif) les différentes syntaxes trouvées (j&#8217;ai arrangé l&#8217;ordre des paramètres pour faciliter la comparaison)</p>
<p>L&#8217;objectif de cet article n&#8217;est pas de donner un mode opération pour créer un certificat et sa clé (je le ferais dans un autre article) mais il s&#8217;agit de mettre en avant la richesse et la difficulté à comprendre ce qui est fait avec la commande openssl&#8230;</p>
<p>(il s&#8217;agit d&#8217;un travail de débroussaillage pour choisir mon mode opératoire)</p>
<p>&nbsp;</p>
<p>Premier point un peu en dehors du sujet, les extensions des fichiers, on trouve de tout :</p>
<ul>
<li>clé :  key,  pem</li>
<li>demande de certificat : csr, pem</li>
<li>certificat : crt, pem</li>
</ul>
<p>Cela montre sans même rentrer dans le détail des commandes la difficulté à s&#8217;y retrouver&#8230;.</p>
<p>&nbsp;</p>
<h2>Création d&#8217;un certificat serveur auto-signé</h2>
<h3>Solution 1 : Génération de la clé et du certificat auto-signé en 1 seule fois</h3>
<p><a rel="next" href="http://blog.shk-desktop.com/565-nginx-serveur-web-complet-bluffant">nginx: serveur web complet bluffant</a></p>
<pre>openssl req -x509 -nodes -days 365 -newkey rsa:1024 -out /etc/nginx/conf.d/default.pem -keyout /etc/nginx/conf.d/default.key
chmod 440 /etc/nginx/conf.d/default.pem /etc/nginx/conf.d/default.key</pre>
<p><a title="Nginx , SSL et plus encore .." href="http://lindev.fr/index.php?post/2010/04/06/Ngins-%2C-SSL-et-plus-encore-..">Nginx , SSL et plus encore ..</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>certificats
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>certificats
openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-x509</span> <span style="color: #660033;">-nodes</span> <span style="color: #660033;">-out</span> mon-site.fr.crt <span style="color: #660033;">-keyout</span> mon-site.fr.key</pre></div></div>

<p>&nbsp;</p>
<h3>Solution 2 : en plusieurs commandes</h3>
<p><a href="#src8">(8)</a></p>
<p>Génération de la clé, génération de la demande de certificat, suppression de la passphrase et auto-signature du certificat</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># cd /usr/local/nginx/conf</span>
<span style="color: #666666; font-style: italic;"># openssl genrsa -des3 -out server.key 1024</span>
<span style="color: #666666; font-style: italic;"># openssl req -new -key server.key -out server.csr</span>
<span style="color: #666666; font-style: italic;"># cp server.key server.key.org</span>
<span style="color: #666666; font-style: italic;"># openssl rsa -in server.key.org -out server.key</span>
<span style="color: #666666; font-style: italic;"># openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt</span></pre></div></div>

<p>&nbsp;</p>
<h2>Création d&#8217;une autorité de certification</h2>
<p>La création de l&#8217;autorité de certification peut se faire en plus ou moins d&#8217;étapes, avec divers options voici celles trouvées de ci de là.</p>
<h3>Solution 1 : Génération de la clé et du certificat en 1 seule fois</h3>
<p><a href="#src3">(3)</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl req <span style="color: #660033;">-x509</span> <span style="color: #660033;">-newkey</span> rsa:<span style="color: #000000;">2048</span> <span style="color: #660033;">-days</span> <span style="color: #000000;">1825</span> <span style="color: #660033;">-keyout</span> private<span style="color: #000000; font-weight: bold;">/</span>cacertkey.pem <span style="color: #660033;">-out</span> cacert.pem</pre></div></div>

<p><a href="#src4">(4)</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl req <span style="color: #660033;">-x509</span> <span style="color: #660033;">-newkey</span> rsa:<span style="color: #000000;">2048</span> <span style="color: #660033;">-new</span> <span style="color: #660033;">-days</span> <span style="color: #000000;">3650</span> <span style="color: #660033;">-keyout</span> private<span style="color: #000000; font-weight: bold;">/</span>cacert.key <span style="color: #660033;">-out</span> cacert.pem</pre></div></div>

<p><a href="#src6">(6)</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl req <span style="color: #660033;">-x509</span> <span style="color: #660033;">-new</span> <span style="color: #660033;">-days</span> <span style="color: #000000;">1825</span> <span style="color: #660033;">-config</span> openssl.my.cnf <span style="color: #660033;">-extensions</span> v3_ca <span style="color: #660033;">-keyout</span> private<span style="color: #000000; font-weight: bold;">/</span>myca.key <span style="color: #660033;">-out</span> certs<span style="color: #000000; font-weight: bold;">/</span>myca.crt</pre></div></div>

<p>Quelques remarque sur ces syntaxes :</p>
<p>-new est optionnel lorsque -newkey rsa:xxx est spécifié (syntaxe 4) , en en effet ce dernier crée une clé et une demande de certificat tandis que -new ne crée que la demande de certificat.</p>
<p>Dans la syntaxe 6 la clé est générée malgré la seul présence de l&#8217;option -new qui n&#8217;est sensée ne générer que le certificat. Mais en l&#8217;absence du mot-clé -key spécifiant une clé à utiliser pour créer le certificat, une nouvelle clé est générée en utilisant les données du fichier de configuration openssl.conf (ici l&#8217;auteur précise un autre fichier de configuration à utiliser plutôt que celui standard avec l&#8217;option -config)</p>
<p>Enfin il ne s&#8217;agit pas d&#8217;une demande de certificat qui est généré comme indiqué ci-dessus mais directement un certificat grâce à l’adjonction de l&#8217;option -x509</p>
<p>&nbsp;</p>
<h3>Solution 2 : Création de la clé privé puis création du certificat auto-signé</h3>
<p><a href="#src1">(1)</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl genrsa <span style="color: #660033;">-des3</span> <span style="color: #000000;">2048</span> <span style="color: #660033;">-out</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>CA<span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>my-ca.key
openssl <span style="color: #660033;">-req</span> x509 <span style="color: #660033;">-key</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>CA<span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>my-ca.key <span style="color: #660033;">-days</span> <span style="color: #000000;">3650</span> <span style="color: #000000; font-weight: bold;">&gt;</span> my-ca.crt</pre></div></div>

<p><a href="#src7">(7)</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl genrsa <span style="color: #660033;">-des3</span> <span style="color: #000000;">2048</span> <span style="color: #660033;">-out</span> elao-ca.key
openssl req <span style="color: #660033;">-x509</span> <span style="color: #660033;">-new</span> <span style="color: #660033;">-key</span> elao-ca.key <span style="color: #660033;">-days</span> <span style="color: #000000;">3650</span> <span style="color: #660033;">-out</span> elao-ca.crt</pre></div></div>

<p>La différence entre ces 2 sources réside dans l&#8217;utilisation de 2 commandes différentes.</p>
<ul>
<li>req qui permet de générer un nouveau (-new) certificat auto-signé (-x509)</li>
<li>x509 utilitaire de gestion des certificats (affichage, conversion) utilisé ici pour créer un nouveau certificat (-req)</li>
</ul>
<p>Et de la méthode sortie (option out contre redirection)</p>
<h3>Solution 3 : Création de la clé privé, demande de certificat et signature du certificat</h3>
<p><a href="#src2">(2)</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl genrsa <span style="color: #660033;">-des3</span> <span style="color: #660033;">-out</span> ca.key <span style="color: #000000;">2048</span>
openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-key</span> ca.key <span style="color: #660033;">-out</span> ca.csr
openssl x509 <span style="color: #660033;">-req</span> <span style="color: #660033;">-days</span> <span style="color: #000000;">3650</span> <span style="color: #660033;">-in</span> ca.csr <span style="color: #660033;">-signkey</span> ca.key <span style="color: #660033;">-out</span> ca.crt</pre></div></div>

<p>&nbsp;</p>
<h2>Création d&#8217;un certificat serveur et signature par l&#8217;autorité de certification</h2>
<h3>Solution 1 : Création de la clé, suppression du mot de passe, demande de certificat, signature du certificat avec notre autorité</h3>
<p><a href="#src2">(2)</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl genrsa <span style="color: #660033;">-des3</span> <span style="color: #660033;">-out</span> server.key <span style="color: #000000;">1024</span>
openssl rsa <span style="color: #660033;">-in</span> server.key <span style="color: #660033;">-out</span> server.key
openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-key</span> server.key <span style="color: #660033;">-out</span> server.csr
openssl x509 <span style="color: #660033;">-req</span> <span style="color: #660033;">-in</span> server.csr <span style="color: #660033;">-out</span> server.crt <span style="color: #660033;">-CA</span> ca.crt <span style="color: #660033;">-CAkey</span> ca.key <span style="color: #660033;">-CAcreateserial</span></pre></div></div>

<p><a href="#src7">(7)</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl genrsa <span style="color: #660033;">-des3</span> <span style="color: #660033;">-out</span> elao-server.key <span style="color: #000000;">1024</span>
openssl rsa <span style="color: #660033;">-in</span> elao-server.key <span style="color: #660033;">-out</span> elao-server.key.insecure
openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-key</span> elao-server.key <span style="color: #660033;">-out</span> elao-server.csr
openssl x509 <span style="color: #660033;">-req</span> <span style="color: #660033;">-in</span> elao-server.csr <span style="color: #660033;">-out</span> elao-server.crt <span style="color: #660033;">-sha1</span> <span style="color: #660033;">-CA</span> elao-ca.crt <span style="color: #660033;">-CAkey</span> elao-ca.key <span style="color: #660033;">-CAcreateserial</span> <span style="color: #660033;">-days</span> <span style="color: #000000;">3650</span></pre></div></div>

<p>L&#8217;option -CAcreateserial n&#8217;est nécessaire que lors de la signature du premier certificat par notre autorité de certification, elle peut même ne pas être nécessaire du tout si on a créé préalablement le fichier paramétré sous le nome database dans le fichier openssl.conf.</p>
<p>&nbsp;</p>
<h3>Solution 2 : Création de la clé sans mot de passe,  demande de certificat, signature du certificat avec notre autorité</h3>
<p><a href="#src1">(1)</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl genrsa <span style="color: #000000;">1024</span> <span style="color: #660033;">-out</span> www.test.net.key
openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-key</span> www.test.net.key <span style="color: #660033;">-out</span> www.test.net.csr
openssl ca <span style="color: #660033;">-in</span> www.test.net.csr <span style="color: #660033;">-out</span> www.test.net.crt</pre></div></div>

<p>Le fait de ne pas mettre l&#8217;option -des3 génère une clé directement sans mot de passe</p>
<p>La signature se fait avec la commande ca au lieu de x509, mais je ne comprends pas pas où l&#8217;on spécifie que l&#8217;on doit utiliser notre autorité de certification, son certificat et sa clé (my-ca.crt et my-ca.key, voir ci-dessus solution 2)</p>
<p>Pour moi avec cette méthode le certificat généré est auto-signé ce qui n&#8217;est pas le but recherché.</p>
<p>&nbsp;</p>
<h3>Solution 3 : Création de la clé et de la demande de certificat, signature du certificat avec notre autorité</h3>
<p><a href="#src3">(3)</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl req <span style="color: #660033;">-newkey</span> rsa:<span style="color: #000000;">2048</span> <span style="color: #660033;">-keyout</span> private<span style="color: #000000; font-weight: bold;">/</span>server.key <span style="color: #660033;">-out</span> server-req.pem
openssl ca <span style="color: #660033;">-in</span> serveur-req.pem <span style="color: #660033;">-out</span> signedcerts<span style="color: #000000; font-weight: bold;">/</span>serveur-cert.pem <span style="color: #660033;">-cert</span> cacert.pem <span style="color: #660033;">-keyfile</span> private<span style="color: #000000; font-weight: bold;">/</span>cacertkey.pem <span style="color: #660033;">-days</span> <span style="color: #000000;">365</span></pre></div></div>

<p><a href="#src6">(6)</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-keyout</span> private<span style="color: #000000; font-weight: bold;">/</span>server.key <span style="color: #660033;">-out</span> server.csr <span style="color: #660033;">-config</span> openssl.my.cnf <span style="color: #660033;">-nodes</span> <span style="color: #660033;">-days</span> <span style="color: #000000;">365</span>
openssl ca <span style="color: #660033;">-infiles</span> server.csr <span style="color: #660033;">-out</span> certs<span style="color: #000000; font-weight: bold;">/</span>server.crtc <span style="color: #660033;">-config</span> openssl.my.cnf <span style="color: #660033;">-policy</span> policy_anything</pre></div></div>

<p>Concernant les commande de génération de al clé et de la demande de certificat :</p>
<ul>
<li>-new ne  crée que la clé sauf si on n&#8217;utilise pas l&#8217;option -key auquel cas la clé est aussi générée</li>
<li>-newkey rsa:xxx crée une clé et un certificat</li>
<li>Ce sont des demandes de certificat qui sont générés (contrairement aux commandes que l&#8217;on a utilisé pour la création de l&#8217;autorité de certification solution 1) car nous n&#8217;avons pas l&#8217;option -x509</li>
<li>L&#8217;option -nodes permet d&#8217;indiquer que la clé qui doit être générée ne doit pas être protégée par un mot de passe (passphrase)</li>
</ul>
<p>Enfin les commande de signature des certificats doivent pouvoir être simplifiées comme dans la solution 2 (juste -in et -out)</p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><em><strong>Sources :</strong></em></span></p>
<ol>
<li><a name="src1"></a><a rel="prev" href="http://www.404blog.net/?p=122">Openssl – création d’une autorité de certification</a> et <a href="http://www.404blog.net/?p=165">Openssl – générer et signer une demande de signature(CSR) | 404Blog</a></li>
<li><a name="src2"></a><a title="Permalink to Autorité de certification openssl" href="http://linux-attitude.fr/post/autorite-de-certification-openssl">Autorité de certification openssl</a> et <a title="Permalink to Autorité de certification, le retour" href="http://linux-attitude.fr/post/autorite-de-certification-le-retour">Autorité de certification, le retour</a></li>
<li><a name="src3"></a><a href="http://www.k-tux.com/openssl-creation-et-mise-en-place-dune-pki/2">OpenSSL : création et mise en place d’une PKI &#8211; K-Tux</a></li>
<li><a name="src4"></a><a href="http://www.systemx.fr/linux/openssl/openssl-p.html">Openssl pratique</a></li>
<li><a name="src5"></a><a title="Nginx , SSL et plus encore .." href="http://lindev.fr/index.php?post/2010/04/06/Ngins-%2C-SSL-et-plus-encore-..">Nginx , SSL et plus encore ..</a></li>
<li><a name="src6"></a><a title="Be your own Certificate Authority (CA)" rel="bookmark" href="http://www.g-loaded.eu/2005/11/10/be-your-own-ca/">Be your own Certificate Authority (CA)</a></li>
<li><a name="src7"></a><a title="Permanent Link to Créer une autorité de certification et des certificats SSL auto-signés" rel="bookmark" href="http://www.elao.org/linux/creer-une-autorite-de-certification-et-des-certificats-ssl-auto-signes.html">Créer une autorité de certification et des certificats SSL auto-signés</a></li>
<li><a name="src8"></a><a href="http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html">Top 20 Nginx WebServer Best Security Practices</a></li>
</ol>
<p>A voir pour les extensions de  fichier :</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/X.509">http://en.wikipedia.org/wiki/X.509</a></li>
<li><a href="http://marc.info/?l=openssl-users&amp;m=128008468329998&amp;w=2">http://marc.info/?l=openssl-users&amp;m=128008468329998&amp;w=2</a></li>
<li><a title="Be your own Certificate Authority (CA)" rel="bookmark" href="http://www.g-loaded.eu/2005/11/10/be-your-own-ca/">Be your own Certificate Authority (CA)</a></li>
</ul>
<p>Source d&#8217;info sur les commandes les pages MAN (par contre il faut s&#8217;y retrouver avec toutes les options !!)</p>
<ul>
<li><a href="http://www.openssl.org/docs/apps/req.html#">req</a></li>
<li><a href="http://www.openssl.org/docs/apps/x509.html#">x509</a></li>
<li><a href="http://www.openssl.org/docs/apps/openssl.html">openssl</a></li>
<li><a href="http://www.openssl.org/docs/apps/ca.html#">ca</a></li>
<li><a href="http://www.openssl.org/docs/apps/genrsa.html#">genrsa</a></li>
</ul>
<p>Image par <a href="http://www.flickr.com/photos/epitti/">Erik Pitti</a> (photo de la machine Enigma utilisé par les Allemands lors de la 2de guerre mondial pour crypter leur communication)</p>
]]></content:encoded>
			<wfw:commentRss>http://voidandany.free.fr/index.php/openssl-puissance-et-complexite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
