tp2 finit

This commit is contained in:
2022-10-21 10:57:50 +02:00
parent 141fd0f1ef
commit a655ebe44d
10 changed files with 94 additions and 22 deletions

View File

@@ -1,6 +1,6 @@
<?php
require('./config.php');
require('./config.php'); //Contient le chemin vers le fichier de config d'openssl
$dn = array(
"countryName" => "FR",
@@ -12,12 +12,14 @@ $dn = array(
"emailAddress" => "iut@univ.fr"
);
$pk = openssl_pkey_new($config);
$req = openssl_csr_new($dn, $pk, $config);
$certif = openssl_csr_sign($req, null, $pk, (365*3), $config);
$exportCertif = openssl_x509_export_to_file($certif, "./a/certificat");
$exportReq = openssl_csr_export_to_file($req, "./a/requete");
$exportKey = openssl_pkey_export_to_file($pk, "./a/clePrivee", null, $config);
//on créé un tableau de données pour la création du certificat
$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*3), $config); //création d'un certificat valide pour 3 ans
$exportCertif = openssl_x509_export_to_file($certif, "./a/certificat"); //exportation certificat
$exportReq = openssl_csr_export_to_file($req, "./a/requete"); //exportation CSR
$exportKey = openssl_pkey_export_to_file($pk, "./a/clePrivee", null, $config); //exportation cléPrivée
echo "Certificat exporté<br />";
echo "Requête exportée<br />";