29 lines
1.0 KiB
PHP
Raw Normal View History

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
$dn = array(
"countryName" => "FR",
"stateOrProvinceName" => "Sophia",
"localityName" => "Valbonne",
"organizationName" => "iut",
"organizationalUnitName" => "iut_iotia",
"commonName" => "b",
"emailAddress" => "iut@univ.fr"
);
2022-10-21 10:57:50 +02:00
//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
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 />";