tp2 finit
This commit is contained in:
18
TD/TD2/b.php
18
TD/TD2/b.php
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
require('./config.php');
|
||||
require('./config.php'); //Contient le chemin vers le fichier de config d'openssl
|
||||
|
||||
if( isset($_POST["Pays"]) && $_POST["Pays"] != '' &&
|
||||
isset($_POST["Département"]) && $_POST["Département"] != '' &&
|
||||
@@ -9,7 +9,7 @@ if( isset($_POST["Pays"]) && $_POST["Pays"] != '' &&
|
||||
isset($_POST["Unite"]) && $_POST["Unite"] != '' &&
|
||||
isset($_POST["Nom"]) && $_POST["Nom"] != '' &&
|
||||
isset($_POST["Prenom"]) && $_POST["Prenom"] != '' &&
|
||||
isset($_POST["Email"]) && $_POST["Email"] != '' ) {
|
||||
isset($_POST["Email"]) && $_POST["Email"] != '' ) { //vérification que tous les champs du formulaires sont inscrits
|
||||
$dn = array(
|
||||
"countryName" => $_POST["Pays"],
|
||||
"stateOrProvinceName" => $_POST["Département"],
|
||||
@@ -18,13 +18,13 @@ if( isset($_POST["Pays"]) && $_POST["Pays"] != '' &&
|
||||
"organizationalUnitName" => $_POST["Unite"],
|
||||
"commonName" => '$_POST["Nom"]' . ' ' .'$_POST["Prenom"]',
|
||||
"emailAddress" => $_POST["Email"]
|
||||
);
|
||||
$pk = openssl_pkey_new($config);
|
||||
$req = openssl_csr_new($dn, $pk, $config);
|
||||
$certif = openssl_csr_sign($req, null, $pk, (365), $config);
|
||||
$exportCertif = openssl_x509_export_to_file($certif, "./b/certificat");
|
||||
$exportReq = openssl_csr_export_to_file($req, "./b/requete");
|
||||
$exportKey = openssl_pkey_export_to_file($pk, "./b/clePrivee", null, $config);
|
||||
); //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
|
||||
|
||||
echo "Certificat exporté<br />";
|
||||
echo "Requête exportée<br />";
|
||||
|
Reference in New Issue
Block a user