2022-10-07 12:02:36 +02:00
|
|
|
<?php
|
|
|
|
|
2022-10-21 10:57:50 +02:00
|
|
|
require('./config.php'); //Contient le chemin vers le fichier de config d'openssl
|
2022-10-07 12:02:36 +02:00
|
|
|
|
2022-10-14 12:05:34 +02:00
|
|
|
if( isset($_POST["Pays"]) && $_POST["Pays"] != '' &&
|
|
|
|
isset($_POST["Département"]) && $_POST["Département"] != '' &&
|
|
|
|
isset($_POST["Ville"]) && $_POST["Ville"] != '' &&
|
|
|
|
isset($_POST["Organisation"]) && $_POST["Organisation"] != '' &&
|
|
|
|
isset($_POST["Unite"]) && $_POST["Unite"] != '' &&
|
|
|
|
isset($_POST["Nom"]) && $_POST["Nom"] != '' &&
|
|
|
|
isset($_POST["Prenom"]) && $_POST["Prenom"] != '' &&
|
2022-10-21 10:57:50 +02:00
|
|
|
isset($_POST["Email"]) && $_POST["Email"] != '' ) { //vérification que tous les champs du formulaires sont inscrits
|
2022-10-07 12:02:36 +02:00
|
|
|
$dn = array(
|
2022-10-14 12:05:34 +02:00
|
|
|
"countryName" => $_POST["Pays"],
|
|
|
|
"stateOrProvinceName" => $_POST["Département"],
|
|
|
|
"localityName" => $_POST["Ville"],
|
|
|
|
"organizationName" => $_POST["Organisation"],
|
|
|
|
"organizationalUnitName" => $_POST["Unite"],
|
|
|
|
"commonName" => '$_POST["Nom"]' . ' ' .'$_POST["Prenom"]',
|
|
|
|
"emailAddress" => $_POST["Email"]
|
2022-10-21 10:57:50 +02:00
|
|
|
); //on créé un tableau de données pour la création du certificat à partir des données du formulatire
|
|
|
|
$pk = openssl_pkey_new($config);//création de clé privée
|
|
|
|
$req = openssl_csr_new($dn, $pk, $config);// création d'un CSR
|
|
|
|
$certif = openssl_csr_sign($req, null, $pk, (365), $config); //création d'un certificat valide pour 1 an
|
|
|
|
$exportCertif = openssl_x509_export_to_file($certif, "./b/certificat"); //exportation certificat
|
|
|
|
$exportReq = openssl_csr_export_to_file($req, "./b/requete"); //exportation CSR
|
|
|
|
$exportKey = openssl_pkey_export_to_file($pk, "./b/clePrivee", null, $config); //exportation cléPrivée
|
2022-10-07 12:02:36 +02:00
|
|
|
|
|
|
|
echo "Certificat exporté<br />";
|
|
|
|
echo "Requête exportée<br />";
|
|
|
|
echo "Clée privée exportée<br />";
|
2022-10-14 12:05:34 +02:00
|
|
|
} else {
|
|
|
|
echo '<h1 style="color:#ff0000">Merci de rentez toutes les valeurs demandeés et corectement SVP </h1>';
|
2022-10-07 12:02:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<html>
|
|
|
|
<form method="POST" action="b.php">
|
|
|
|
<label for="Nom">Nom</label> <input type="text" name="Nom" id="Nom" value=""/><br />
|
|
|
|
<label for="Prenom">Prenom</label> <input type="text" name="Prenom" id="Prenom" value=""/><br />
|
|
|
|
<label for="Ville">Ville</label> <input type="text" name="Ville" id="Ville" value=""/><br />
|
|
|
|
<label for="Département">Département</label> <input type="text" name="Département" id="Département" value=""/><br />
|
|
|
|
<label for="Pays">Pays</label> <input type="text" name="Pays" id="Pays" value=""/><br />
|
|
|
|
<label for="Organisation">Organisation</label> <input type="text" name="Organisation" id="Organisation" value=""/><br />
|
|
|
|
<label for="Unite">Unite</label> <input type="text" name="Unite" id="Unite" value=""/><br />
|
2022-10-14 12:05:34 +02:00
|
|
|
<label for="Email">Email</label> <input type="email" name="Email" id="Email" value=""/><br />
|
|
|
|
|
2022-10-07 12:02:36 +02:00
|
|
|
<input type="submit" name="Envoyer" value="Envoyer" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|