débt td2

This commit is contained in:
OMGiTzPomPom 2022-10-07 12:02:36 +02:00
parent e57401d136
commit bd5367f3be
10 changed files with 220 additions and 0 deletions

26
TD/TD2/a.php Normal file
View File

@ -0,0 +1,26 @@
<?php
require('./config.php');
$dn = array(
"countryName" => "FR",
"stateOrProvinceName" => "Sophia",
"localityName" => "Valbonne",
"organizationName" => "iut",
"organizationalUnitName" => "iut_iotia",
"commonName" => "b",
"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);
echo "Certificat exporté<br />";
echo "Requête exportée<br />";
echo "Clée privée exportée<br />";

23
TD/TD2/a/certificat Normal file
View File

@ -0,0 +1,23 @@
-----BEGIN CERTIFICATE-----
MIIDxDCCAqygAwIBAgIBADANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJGUjEP
MA0GA1UECAwGU29waGlhMREwDwYDVQQHDAhWYWxib25uZTEMMAoGA1UECgwDaXV0
MRIwEAYDVQQLDAlpdXRfaW90aWExCjAIBgNVBAMMAWIxGjAYBgkqhkiG9w0BCQEW
C2l1dEB1bml2LmZyMB4XDTIyMTAwNzA5NDEyNFoXDTI1MTAwNjA5NDEyNFowezEL
MAkGA1UEBhMCRlIxDzANBgNVBAgMBlNvcGhpYTERMA8GA1UEBwwIVmFsYm9ubmUx
DDAKBgNVBAoMA2l1dDESMBAGA1UECwwJaXV0X2lvdGlhMQowCAYDVQQDDAFiMRow
GAYJKoZIhvcNAQkBFgtpdXRAdW5pdi5mcjCCASIwDQYJKoZIhvcNAQEBBQADggEP
ADCCAQoCggEBAKTjKuZWKCxhjtwCVeDu4uYZ98emKbJc9UloO8f7bcWclCyltN6I
9EyhfCcj82/RDg86TKlKvraIf4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SeRjKx/naI+onkmvVFvRe68y+CyOZK/m7otH7NmC3TFnZOV802MEe
B1KlRCavD2z0dSr7ylZj+ajt4TafkAqjsKt0huPNiRYDMOpiIitECvzMB1HkrHmn
LYmJlix6An5uT1kAXinPOQ3Dmi23mfMwtzMAXMBtWQKBgQCAJ6rAW+S+osjLjLZ7
EQ+GJDl5+diGC40EQ3qhiek4P1O3yFJAHsSf85PTEbcOUmYBQbQ25EirO72FoypZ
srxFirR6dllH63TiqBbimvgYP/7ESeT5VPJgdTAPgKAZePDhEJsCBf/XR3S+2YKd
N/bXMZXi92sxnqotp4vhfVsaFw==
-----END PRIVATE KEY-----

17
TD/TD2/a/requete Normal file
View File

@ -0,0 +1,17 @@
-----BEGIN CERTIFICATE REQUEST-----
MIICwDCCAagCAQAwezELMAkGA1UEBhMCRlIxDzANBgNVBAgMBlNvcGhpYTERMA8G
A1UEBwwIVmFsYm9ubmUxDDAKBgNVBAoMA2l1dDESMBAGA1UECwwJaXV0X2lvdGlh
MQowCAYDVQQDDAFiMRowGAYJKoZIhvcNAQkBFgtpdXRAdW5pdi5mcjCCASIwDQYJ
KoZIhvcNAQEBBQADggEPADCCAQoCggEBAKTjKuZWKCxhjtwCVeDu4uYZ98emKbJc
9UloO8f7bcWclCyltN6I9EyhfCcj82/RDg86TKlKvraIf4Z9AFJP0LMtpej7r5iU
DGGw+NZgTifbLi0mhNhy/TaFttF3OnupWgbSlATUmVRQ5QCQoA1ugr1hMO004F3W
gdgh3q0bS+8i6dq5cidFm0NfiFbncKgFUKRhTIJdkIqugI5E6H1GsGGczmvkRIYY
lkn2gIhruMOODbBWMDW9L4zq+qpU4aLRa/MqEpZxvFG4PiF7016EfGIgyOPz2JfS
3c6Yn3/SaeGUraibqIG1tMDsWkVWCzif9qdlsyUumjn2S5YXyaX+S/8CAwEAAaAA
MA0GCSqGSIb3DQEBBQUAA4IBAQBKcTQ/hjXhp8OgfRg5fmqqwv1/yCuPwN57N20T
0LMbTmHvXNpPPN4aub3TVJWbRRZfTdr3UOr65OScLQliRArTH+tU9kw+A5bQrIbY
TGvtlgfmpqEHSt0IovHwVh+2kxOw+GNNJK2eNv2dn83hHfByhy88Hg7JMWWlmiCj
pAD+oOgLjJhuQgNo8puli5QgRYN2jogdHJn55dOBCQxuvvBHJ0x6MJ2pBxnWtxDd
LYSo3SVW8bsQMOABfnIs1nYtjPBS0QUp2w2zvm94hwseoX+doyq8tHaai7n2oVev
OFvxeU78a/5CTKBOntbRxj5I6ZX9Z9mkoir+zq7TYuDv42gW
-----END CERTIFICATE REQUEST-----

47
TD/TD2/b.php Normal file
View File

@ -0,0 +1,47 @@
<?php
$form = $_POST;
require('./config.php');
if(isset($_POST['Nom'])) {
$dn = array(
"countryName" => "FR",
"stateOrProvinceName" => "Alpes Maritimes",
"localityName" => "Nice",
"organizationName" => "iut",
"organizationalUnitName" => "iotia",
"commonName" => "Pauline Srifi",
"emailAddress" => "pauline@srifi.fr"
);
$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);
echo "Certificat exporté<br />";
echo "Requête exportée<br />";
echo "Clée privée exportée<br />";
}
?>
<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 />
<input type="submit" name="Envoyer" value="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EB/zANBgkqhkiG9w0BAQUFAAOCAQEAJpO+QSO2QBgvIurd3rne+F11
POVaqT84xgR04CjpaYT3p32G5hOKAjamiBfY6Mv+3htT5EANK1ODhbqQSTDn82tj
mVzaSWnaBRYOLRVkssxWrD567xeYCAEKR2sgB0+f+yjtHfHrN8JeGuMhzjtLwUfS
9tl3lxUndwC4uJlTr9Zk9KbSX5CNnhEV31VpS/m799Kwse7s96pMCTY463vAiQZA
GtM/M280KJx+Xe2x2fWj+fH1EaOvjLH8EUkuaaxQxVt+mJatM+qiBUasL2rgrdF0
XGQU/zNT8we/6i4Y8wpBMoC7bkxrlUgU3IQyLcSe0JflLyXb3WPec1fSQPthxA==
-----END CERTIFICATE-----

28
TD/TD2/b/clePrivee Normal file
View File

@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDBFVrakcnS7owG
st2NsfWy1DthRoAZov77VvuS2uOytF36DeJJlqYkjVJr/10kk4iKvDYQm1Ro7zeK
Qd0ggNZRKk0dWfkHMsdqydZd4jnwJnQR9Xk8OgJlCNbhA2MWHDOTFwg7ylDjdRch
t2feCRE54hTzNvioEt2uQA+5gNFQ6Lj7Bw3Abi35icit2eAK8G48CvVY9L+sr2pW
gS9yNKQWLhsae/Q5nanDTnBjX3nLkOXqXofXuwX81VxaxOh+Ww4JpNM5zKfvlVSZ
dZ88tPW0O8yiMCVR2QsSWJCjuwcI3ORxrnWg0pD4wR164zIdAyYRceU1OnTJy5sq
/pDIVqEpAgMBAAECggEBALboRufUwY7q4YUa/dxT3//nItU0lvcyPD/Wl3z3lEne
qUPO0TWK25q2sYSTJSYYCHn8b27t5ll9e2yilhpLUjsTSnfqmoiiJtzXlRXcz6va
kYvNsWpHPat+YyhHMB9q2cSWRft13YiLjD0pY+CnUEU4EUaRJZ76ODvwfbTp/d+Y
4A+3zZ7knQqGn3ikflHVdgcix6mWQrzEEo3MTkfGBQiBowEJn7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0 +1,3 @@
<?php
require('./config.php');

7
TD/TD2/config.php Normal file
View File

@ -0,0 +1,7 @@
<?php
$config = array(
"config" => "C:\\laragon\\bin\\php\\php-8.1.10-Win32-vs16-x64\\extras\\ssl\\openssl.cnf"
);
?>