mirror of
https://github.com/tips-of-mine/gestion-certificats2.git
synced 2025-07-02 01:08:43 +02:00
Merge pull request #10 from tips-of-mine/fix/functional-perimeter-creation
Fix/functional perimeter creation
This commit is contained in:
@ -81,6 +81,8 @@ if ($userCount === 0 || !$rootCertExists) {
|
||||
if (isset($_POST['admin_password'], $_POST['root_domain']) && !empty($_POST['admin_password']) && !empty($_POST['root_domain'])) {
|
||||
$_SESSION['init_admin_password'] = $_POST['admin_password'];
|
||||
$_SESSION['init_root_domain'] = $_POST['root_domain'];
|
||||
$logService->log('debug', 'Initialisation - POST data received: admin_password_present=' . !empty($_POST['admin_password']) . ', root_domain=' . ($_POST['root_domain'] ?? 'not_set_or_empty'));
|
||||
$logService->log('debug', 'Initialisation - Session variables SET: init_admin_password_present=' . !empty($_SESSION['init_admin_password']) . ', init_root_domain=' . ($_SESSION['init_root_domain'] ?? 'not_set_or_empty'));
|
||||
header('Location: ' . $_SERVER['PHP_SELF']);
|
||||
exit();
|
||||
} else {
|
||||
@ -108,6 +110,25 @@ if ($userCount === 0 || !$rootCertExists) {
|
||||
if (!$rootCertExists) {
|
||||
echo "<p>Création du certificat Root CA en cours...</p>";
|
||||
$logService->log('info', 'Lancement de la création du certificat Root CA pour le domaine: ' . $_SESSION['init_root_domain'], null, $_SERVER['REMOTE_ADDR']);
|
||||
|
||||
$logService->log('debug', 'Initialisation - About to call create_root_cert.sh. Value of $_SESSION[\'init_root_domain\']: ' . ($_SESSION['init_root_domain'] ?? 'NOT SET OR EMPTY'));
|
||||
if (empty($_SESSION['init_root_domain'])) {
|
||||
$logService->log('error', 'Initialisation - CRITICAL: $_SESSION[\'init_root_domain\'] is empty or not set right before calling create_root_cert.sh. Forcing display of error and form again.');
|
||||
// Code to re-display form or a clear error message, then exit.
|
||||
// This is to prevent the script from being called with an empty argument.
|
||||
echo "<p style='color: red;'><strong>Erreur Critique:</strong> La variable de session pour le domaine racine est vide avant d'appeler le script de création. Veuillez réessayer.</p>";
|
||||
// Minimal form for resubmission:
|
||||
echo "<form method='POST' action='" . htmlspecialchars($_SERVER['PHP_SELF']) . "'>";
|
||||
echo "<div><label for='admin_password'>Mot de passe administrateur initial :</label><input type='password' id='admin_password' name='admin_password' required></div>";
|
||||
echo "<div><label for='root_domain'>Domaine racine (ROOT_DOMAIN) pour le certificat CA :</label><input type='text' id='root_domain' name='root_domain' required><small>Exemple: exemple.com</small></div>";
|
||||
echo "<button type='submit'>Configurer</button>";
|
||||
echo "</form>";
|
||||
// Optionally, unset session variables to force re-entry of CAS 1.2 logic fully.
|
||||
unset($_SESSION['init_admin_password']);
|
||||
unset($_SESSION['init_root_domain']);
|
||||
exit();
|
||||
}
|
||||
|
||||
// Exécution du script shell de création de certificat root avec le domaine racine
|
||||
$command = escapeshellcmd(SCRIPTS_PATH . '/create_root_cert.sh ' . escapeshellarg($_SESSION['init_root_domain']));
|
||||
$output = shell_exec($command . ' 2>&1');
|
||||
|
Reference in New Issue
Block a user