Skip to content

Commit 5235287

Browse files
committed
CSR request generator
1 parent 0e3bda7 commit 5235287

File tree

15 files changed

+416
-23
lines changed

15 files changed

+416
-23
lines changed

web/generate/ssl/index.php

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?php
2+
// Init
3+
error_reporting(NULL);
4+
session_start();
5+
$TAB = 'WEB';
6+
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
7+
8+
// Header
9+
include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
10+
11+
// Panel
12+
top_panel($user,$TAB);
13+
14+
// Prepare values
15+
if (!empty($_GET['domain'])) {
16+
$v_domain = $_GET['domain'];
17+
} else {
18+
$v_domain = 'example.ltd';
19+
}
20+
$v_email = 'admin@' . $v_domain;
21+
$v_country = 'US';
22+
$v_state = 'California';
23+
$v_locality = 'San Francisco';
24+
$v_org = 'MyCompany LLC';
25+
$v_org_unit = 'IT';
26+
27+
// Back uri
28+
$_SESSION['back'] = '';
29+
30+
// Check POST
31+
if (!isset($_POST['generate'])) {
32+
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/generate_ssl.html');
33+
include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');
34+
exit();
35+
}
36+
37+
// Check input
38+
if (empty($_POST['v_domain'])) $errors[] = __('domain');
39+
if (empty($_POST['v_country'])) $errors[] = __('country');
40+
if (empty($_POST['v_state'])) $errors[] = __('domain');
41+
if (empty($_POST['v_locality'])) $errors[] = __('city');
42+
if (empty($_POST['v_org'])) $errors[] = __('organization');
43+
$v_domain = $_POST['v_domain'];
44+
$v_email = $_POST['v_email'];
45+
$v_country = $_POST['v_country'];
46+
$v_state = $_POST['v_state'];
47+
$v_locality = $_POST['v_locality'];
48+
$v_org = $_POST['v_org'];
49+
50+
// Check for errors
51+
if (!empty($errors[0])) {
52+
foreach ($errors as $i => $error) {
53+
if ( $i == 0 ) {
54+
$error_msg = $error;
55+
} else {
56+
$error_msg = $error_msg.", ".$error;
57+
}
58+
}
59+
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
60+
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/generate_ssl.html');
61+
include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');
62+
unset($_SESSION['error_msg']);
63+
exit();
64+
}
65+
66+
// Protect input
67+
$v_domain = escapeshellarg($_POST['v_domain']);
68+
$v_email = escapeshellarg($_POST['v_email']);
69+
$v_country = escapeshellarg($_POST['v_country']);
70+
$v_state = escapeshellarg($_POST['v_state']);
71+
$v_locality = escapeshellarg($_POST['v_locality']);
72+
$v_org = escapeshellarg($_POST['v_org']);
73+
74+
exec (VESTA_CMD."v-generate-ssl-cert ".$v_domain." ".$v_email." ".$v_country." ".$v_state." ".$v_locality." ".$v_org." IT json", $output, $return_var);
75+
76+
// Revert to raw values
77+
$v_domain = $_POST['v_domain'];
78+
$v_email = $_POST['v_email'];
79+
$v_country = $_POST['v_country'];
80+
$v_state = $_POST['v_state'];
81+
$v_locality = $_POST['v_locality'];
82+
$v_org = $_POST['v_org'];
83+
84+
// Check return code
85+
if ($return_var != 0) {
86+
$error = implode('<br>', $output);
87+
if (empty($error)) $error = __('Error code:',$return_var);
88+
$_SESSION['error_msg'] = $error;
89+
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/generate_ssl.html');
90+
include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');
91+
unset($_SESSION['error_msg']);
92+
exit();
93+
}
94+
95+
// OK message
96+
$_SESSION['ok_msg'] = __('SSL_GENERATED_OK');
97+
98+
// Parse output
99+
$data = json_decode(implode('', $output), true);
100+
unset($output);
101+
$v_crt = $data[$v_domain]['CRT'];
102+
$v_key = $data[$v_domain]['KEY'];
103+
$v_csr = $data[$v_domain]['CSR'];
104+
105+
// Back uri
106+
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
107+
108+
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/list_ssl.html');
109+
include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');
110+
unset($_SESSION['ok_msg']);
111+
112+
?>

web/inc/i18n/cz.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
'restart' => 'restart',
8181
'update' => 'aktualizovat',
8282
'generate' => 'generovat',
83+
'Generate CSR' => 'Generovat CSR',
8384
'reread IP' => 'číst IP',
8485

8586
'Adding User' => 'Přidání uživatele',
@@ -102,6 +103,7 @@
102103
'Editing Package' => 'Úprava Package',
103104
'Adding IP address' => 'Editace IP adresy',
104105
'Editing IP Address' => 'Úprava IP adresy',
106+
'Generating CSR' => 'Generování CSR',
105107
'Listing' => 'Výpis',
106108
'Search Results' => 'Výsledky vyhledávání',
107109

@@ -239,6 +241,7 @@
239241
'SSL Certificate' => 'SSL certifikát',
240242
'SSL Key' => 'SSL klíč',
241243
'SSL Certificate Authority / Intermediate' => 'SSL Certifikační autorita / Intermediate',
244+
'SSL CSR' => 'CSR zádost',
242245
'optional' => 'volitelný',
243246
'internal' => 'interní',
244247
'Statistics Authorization' => 'Statistiky autorizace',
@@ -315,8 +318,13 @@
315318
'Last 70 lines of %s.%s.log' => 'Posledních 70 řádků %s.%s.log',
316319
'Download AccessLog' => 'Stáhnout AccessLog',
317320
'Download ErrorLog' => 'Stáhnout ErrorLog',
321+
'Country' => 'Země',
322+
'2 letter code' => 'dvoupísmenný kód',
323+
'State / Province' => 'Kraj',
324+
'City / Locality' => 'Město / Obec',
325+
'Organization' => 'Organizace',
318326

319-
'1 account' => '1 účet',
327+
'1 account' => '1 účet',
320328
'%s accounts' => '%s účtů',
321329
'1 domain' => '1 doména',
322330
'%s domains' => '%s domén',
@@ -351,6 +359,7 @@
351359
'CRON_CREATED_OK' => 'Cron job byl úspěšně vytvořen.',
352360
'IP_CREATED_OK' => 'IP adresa <a href="/edit/ip/?ip=%s"><b>%s</b></a> byla úspěšně vytvořena.',
353361
'PACKAGE_CREATED_OK' => 'Package <a href="/edit/package/?package=%s"><b>%s</b></a> byl úspěšně vytvořen.',
362+
'SSL_GENERATED_OK' => 'SSL certifikát byl úspěšně vygenerován.',
354363
'Changes has been saved.' => 'Změny byly uloženy.',
355364
'Confirmation' => 'Potvrzení',
356365
'DELETE_USER_CONFIRMATION' => 'Opravdu chcete odstranit uživatele %s?',

web/inc/i18n/de.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
'restart' => 'Neustarten',
8080
'update' => 'Aktualisieren',
8181
'generate' => 'Generieren',
82+
'Generate CSR' => 'CSR generieren',
8283
'reread IP' => 'IP aktualisieren',
8384

8485
'Adding User' => 'Benutzer anlegen',
@@ -101,6 +102,7 @@
101102
'Editing Package' => 'Packet bearbeiten',
102103
'Adding IP address' => 'IP hinzufügen',
103104
'Editing IP Address' => 'IP bearbeiten',
105+
'Generating CSR' => 'CSR generieren',
104106
'Listing' => 'Auflistung',
105107
'Search Results' => 'Suchergebnisse',
106108

@@ -238,6 +240,7 @@
238240
'SSL Certificate' => 'SSL Zertifikat',
239241
'SSL Key' => 'SSL Schlüssel',
240242
'SSL Certificate Authority / Intermediate' => 'SSL Zertifikat Ersteller',
243+
'SSL CSR' => 'CSR-Anfrage',
241244
'optional' => 'Freiwillig',
242245
'internal' => 'Intern',
243246
'Statistics Authorization' => 'Statistik Autorisierung',
@@ -314,8 +317,13 @@
314317
'Last 70 lines of %s.%s.log' => 'Die letzten 70 Zeilen von %s.%s.log',
315318
'Download AccessLog' => 'AccessLog runterladen',
316319
'Download ErrorLog' => 'ErrorLog runterladen',
320+
'Country' => 'Land',
321+
'2 letter code' => '2-Buchstaben-Code',
322+
'State / Province' => 'Staat / Provinz',
323+
'City / Locality' => 'Stadt / Lokalitat',
324+
'Organization' => 'Organisation',
317325

318-
'1 account' => '1 Konto',
326+
'1 account' => '1 Konto',
319327
'%s accounts' => '%s Konten',
320328
'1 domain' => '1 Domäne',
321329
'%s domains' => '%s Domänen',
@@ -350,6 +358,7 @@
350358
'CRON_CREATED_OK' => 'Cron Job wurde erfolgreich angelegt.',
351359
'IP_CREATED_OK' => 'IP Adresse <a href="/edit/ip/?ip=%s"><b>%s</b></a> wurde erfolgreich hinzugefügt.',
352360
'PACKAGE_CREATED_OK' => 'Packet <a href="/edit/package/?package=%s"><b>%s</b></a> wurde erfolgreich angelegt.',
361+
'SSL_GENERATED_OK' => 'SSL zertifikat wurde erfolgreich angelegt.',
353362
'Changes has been saved.' => 'Änderungen wurden gespeichert.',
354363
'Confirmation' => 'Bestätigung',
355364
'DELETE_USER_CONFIRMATION' => '%s wirklich löschen?',

web/inc/i18n/en.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
'restart' => 'restart',
8181
'update' => 'update',
8282
'generate' => 'generate',
83+
'Generate CSR' => 'Generate CSR',
8384
'reread IP' => 'reread IP',
8485

8586
'Adding User' => 'Adding User',
@@ -102,6 +103,7 @@
102103
'Editing Package' => 'Editing Package',
103104
'Adding IP address' => 'Adding IP address',
104105
'Editing IP Address' => 'Editing IP Address',
106+
'Generating CSR' => 'Generating CSR',
105107
'Listing' => 'Listing',
106108
'Search Results' => 'Search Results',
107109

@@ -239,6 +241,7 @@
239241
'SSL Certificate' => 'SSL Certificate',
240242
'SSL Key' => 'SSL Key',
241243
'SSL Certificate Authority / Intermediate' => 'SSL Certificate Authority / Intermediate',
244+
'SSL CSR' => 'SSL CSR',
242245
'optional' => 'optional',
243246
'internal' => 'internal',
244247
'Statistics Authorization' => 'Statistics Authorization',
@@ -315,6 +318,11 @@
315318
'Last 70 lines of %s.%s.log' => 'Last 70 lines of %s.%s.log',
316319
'Download AccessLog' => 'Download AccessLog',
317320
'Download ErrorLog' => 'Download ErrorLog',
321+
'Country' => 'Country',
322+
'2 letter code' => '2 letter code',
323+
'State / Province' => 'State / Province',
324+
'City / Locality' => 'City / Locality',
325+
'Organization' => 'Organization',
318326

319327
'1 account' => '1 account',
320328
'%s accounts' => '%s accounts',
@@ -351,6 +359,7 @@
351359
'CRON_CREATED_OK' => 'Cron job has been created successfully.',
352360
'IP_CREATED_OK' => 'IP address <a href="/edit/ip/?ip=%s"><b>%s</b></a> has been created successfully.',
353361
'PACKAGE_CREATED_OK' => 'Package <a href="/edit/package/?package=%s"><b>%s</b></a> has been created successfully.',
362+
'SSL_GENERATED_OK' => 'Certificate has been generated successfully.',
354363
'Changes has been saved.' => 'Changes has been saved.',
355364
'Confirmation' => 'Confirmation',
356365
'DELETE_USER_CONFIRMATION' => 'Are you sure to delete user %s?',

web/inc/i18n/es.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
'restart' => 'reiniciar',
8080
'update' => 'actualizar',
8181
'generate' => 'generar',
82+
'Generate CSR' => 'Generar CSR',
8283
'reread IP' => 'releer IP',
8384

8485
'Adding User' => 'Añadiendo Usuario',
@@ -101,6 +102,7 @@
101102
'Editing Package' => 'Editando Plan',
102103
'Adding IP address' => 'Añadiendo Dirección IP',
103104
'Editing IP Address' => 'Editando Dirección IP',
105+
'Generating CSR' => 'Generar solicitud de CSR',
104106
'Listing' => 'Listando',
105107
'Search Results' => 'Resultado de Busqueda',
106108

@@ -238,6 +240,7 @@
238240
'SSL Certificate' => 'Certificado SSL',
239241
'SSL Key' => 'Llave SSL',
240242
'SSL Certificate Authority / Intermediate' => 'Certificado SSL Autoridad / Intermedio',
243+
'SSL CSR' => 'SSL CSR',
241244
'optional' => 'opcional',
242245
'internal' => 'interno',
243246
'Statistics Authorization' => 'Autorización de Estadísticas',
@@ -314,8 +317,13 @@
314317
'Last 70 lines of %s.%s.log' => 'Últimos 70 líneas de %s.%s.log',
315318
'Download AccessLog' => 'Descargar AccessLog',
316319
'Download ErrorLog' => 'Descargar ErrorLog',
320+
'Country' => 'País',
321+
'2 letter code' => 'código de 2 letras',
322+
'State / Province' => 'Estado / Provincia',
323+
'City / Locality' => 'Ciudad / Localidad',
324+
'Organization' => 'Organización',
317325

318-
'1 account' => '1 cuenta',
326+
'1 account' => '1 cuenta',
319327
'%s accounts' => '%s cuentas',
320328
'1 domain' => '1 dominio',
321329
'%s domains' => '%s dominios',
@@ -350,6 +358,7 @@
350358
'CRON_CREATED_OK' => 'Trabajo en Cron ha sido creado correctamente.',
351359
'IP_CREATED_OK' => 'Dirección IP <a href="/edit/ip/?ip=%s"><b>%s</b></a> ha sido creada correctamente.',
352360
'PACKAGE_CREATED_OK' => 'Plan <a href="/edit/package/?package=%s"><b>%s</b></a> ha sido creado correctamente.',
361+
'SSL_GENERATED_OK' => 'SSL certificado ha sido creado correctamente.',
353362
'Changes has been saved.' => 'Los cambios han sido guardados.',
354363
'Confirmation' => 'Confirmación',
355364
'DELETE_USER_CONFIRMATION' => '¿Está seguro que desea eliminar el usuario %s?',

web/inc/i18n/pt.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
'restart' => 'reiniciar',
8080
'update' => 'atualizar',
8181
'generate' => 'gerar',
82+
'Generate CSR' => 'Gerar CSR',
8283
'reread IP' => 'ler IP novamente',
8384

8485
'Adding User' => 'Adicionando Usuário',
@@ -101,6 +102,7 @@
101102
'Editing Package' => 'Editando Pacote',
102103
'Adding IP address' => 'Adicionando Endereço IP',
103104
'Editing IP Address' => 'Editando Endereço IP',
105+
'Generating CSR' => 'Gerando CSR',
104106
'Listing' => 'Listando',
105107
'Search Results' => 'Resultados da Busca',
106108

@@ -238,6 +240,7 @@
238240
'SSL Certificate' => 'Cerificado SSL',
239241
'SSL Key' => 'Chave SSL',
240242
'SSL Certificate Authority / Intermediate' => 'Autoridade Certificadora SSL / Intermediária',
243+
'SSL CSR' => 'SSL CSR (pedido)',
241244
'optional' => 'opcional',
242245
'internal' => 'interno',
243246
'Statistics Authorization' => 'Permissões de Estatística',
@@ -314,8 +317,13 @@
314317
'Last 70 lines of %s.%s.log' => 'Últimas 70 linhas de %s.%s.log',
315318
'Download AccessLog' => 'Baixar AccessLog',
316319
'Download ErrorLog' => 'Baixar ErrorLog',
320+
'Country' => 'País',
321+
'2 letter code' => 'código de duas letras',
322+
'State / Province' => 'Estado / Região',
323+
'City / Locality' => 'Localidade',
324+
'Organization' => 'Organização',
317325

318-
'1 account' => '1 conta',
326+
'1 account' => '1 conta',
319327
'%s accounts' => '%s contas',
320328
'1 domain' => '1 domínio',
321329
'%s domains' => '%s domínio',
@@ -350,6 +358,7 @@
350358
'CRON_CREATED_OK' => 'Tarefa do Cron adicionada com sucesso.',
351359
'IP_CREATED_OK' => 'Endereço IP <a href="/edit/ip/?ip=%s"><b>%s</b></a> criado com sucesso.',
352360
'PACKAGE_CREATED_OK' => 'Pacote <a href="/edit/package/?package=%s"><b>%s</b></a> criado com sucesso.',
361+
'SSL_GENERATED_OK' => 'SSL certificado criado sucesso.',
353362
'Changes has been saved.' => 'As alterações foram salvas.',
354363
'Confirmation' => 'Confirmação',
355364
'DELETE_USER_CONFIRMATION' => 'Tem certeza que deseja deletar o usuário %s?',

web/inc/i18n/ro.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
'restart' => 'repornește',
8282
'update' => 'actualiza',
8383
'generate' => 'generează',
84+
'Generate CSR' => 'Genera cere CSR',
8485
'reread IP' => 'recitește IP',
8586

8687
'Adding User' => 'Adăugare utilizator',
@@ -103,6 +104,7 @@
103104
'Editing Package' => 'Editare pachetul',
104105
'Adding IP address' => 'Adăugare adresă IP',
105106
'Editing IP Address' => 'Editare adresă IP',
107+
'Generate CSR' => 'Cerere CSR',
106108
'Listing' => 'Vizualizare',
107109
'Search Results' => 'Rezultatele căutării',
108110

@@ -240,6 +242,7 @@
240242
'SSL Certificate' => 'Certificat SSL',
241243
'SSL Key' => 'Cheia SSL',
242244
'SSL Certificate Authority / Intermediate' => 'SSL Intermediar / Certificate Authority',
245+
'SSL CSR' => 'Cerere CSR',
243246
'optional' => 'opțional',
244247
'internal' => 'intern',
245248
'Statistics Authorization' => 'Autorizarea statistici',
@@ -316,6 +319,11 @@
316319
'Last 70 lines of %s.%s.log' => 'Ultimele 70 linii de %s.%s.log',
317320
'Download AccessLog' => 'Descarcă AccessLog',
318321
'Download ErrorLog' => 'Descarcă ErrorLog',
322+
'Country' => 'Țară',
323+
'2 letter code' => 'cod de 2 litere',
324+
'State / Province' => 'Județ',
325+
'City / Locality' => 'Oraș / Localitate',
326+
'Organization' => 'Organizație',
319327

320328
'1 account' => '1 utilizator',
321329
'%s accounts' => '%s utilizatori',
@@ -352,6 +360,7 @@
352360
'CRON_CREATED_OK' => 'Sarcina a fost creată cu succes.',
353361
'IP_CREATED_OK' => '"IP adresa <a href="/edit/ip/?ip=%s"><b>%s</b></a> a fost creată cu succes.',
354362
'PACKAGE_CREATED_OK' => 'Pachet <a href="/edit/package/?package=%s"><b>%s</b></a> a fost creat cu succes.',
363+
'SSL_GENERATED_OK' => 'SSL certificat a fost generat cu succes.',
355364
'Changes has been saved.' => 'Modificările au fost salvate.',
356365
'Confirmation' => 'Confirmare',
357366
'DELETE_USER_CONFIRMATION' => 'Ești sigur că dorești să ștergi %s?',

0 commit comments

Comments
 (0)