bernd commited on 2009-07-22 12:07:41
Zeige 5 geänderte Dateien mit 94 Einfügungen und 3 Löschungen.
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1427 87cf0b9e-d624-0410-a070-f6ee81989793
| ... | ... |
@@ -19,7 +19,7 @@ if (count($certs) > 0) |
| 19 | 19 |
output("<table><tr><th>Name/Details</th><th>CommonName</th><th>Gültig ab</th><th>Gültig bis</th><th> </th></tr>");
|
| 20 | 20 |
foreach ($certs as $c) |
| 21 | 21 |
{
|
| 22 |
- output("<tr><td>".internal_link('showcert', $c['subject'], "mode=cert&id={$c['id']}")."</td><td>{$c['cn']}</td><td>{$c['valid_from']}</td><td>{$c['valid_until']}</td><td>".internal_link('savecert', '<img src="'.$prefix.'images/delete.png" />', 'action=delete&id='.$c['id'])."</td></tr>");
|
|
| 22 |
+ output("<tr><td>".internal_link('showcert', $c['subject'], "mode=cert&id={$c['id']}")."</td><td>{$c['cn']}</td><td>{$c['valid_from']}</td><td>{$c['valid_until']}</td><td>".internal_link('refreshcert', '<img src="'.$prefix.'images/refresh.png" title="Neue Version des Zertifikats einspielen" />', 'id='.$c['id'])."   ".internal_link('savecert', '<img src="'.$prefix.'images/delete.png" />', 'action=delete&id='.$c['id'])."</td></tr>");
|
|
| 23 | 23 |
} |
| 24 | 24 |
output("</table>");
|
| 25 | 25 |
} |
| ... | ... |
@@ -36,7 +36,7 @@ function cert_details($id) |
| 36 | 36 |
|
| 37 | 37 |
$result = db_query("SELECT id, lastchange, valid_from, valid_until, subject, cn, cert, `key` FROM vhosts.certs WHERE uid={$uid} AND id={$id}");
|
| 38 | 38 |
if (mysql_num_rows($result) != 1) |
| 39 |
- system_failure("Ungültiges Zertifikat");
|
|
| 39 |
+ system_failure("Ungültiges Zertifikat #{$id}");
|
|
| 40 | 40 |
return mysql_fetch_assoc($result); |
| 41 | 41 |
} |
| 42 | 42 |
|
| ... | ... |
@@ -112,6 +112,20 @@ function save_cert($info, $cert, $key) |
| 112 | 112 |
db_query("INSERT INTO vhosts.certs (uid, subject, cn, valid_from, valid_until, cert, `key`) VALUES ({$uid}, '{$subject}', '{$cn}', '{$valid_from}', '{$valid_until}', '{$cert}', '{$key}')");
|
| 113 | 113 |
} |
| 114 | 114 |
|
| 115 |
+ |
|
| 116 |
+function refresh_cert($id, $info, $cert) |
|
| 117 |
+{
|
|
| 118 |
+ $id = (int) $id; |
|
| 119 |
+ $oldcert = cert_details($id); |
|
| 120 |
+ $cert = mysql_real_escape_string($cert); |
|
| 121 |
+ |
|
| 122 |
+ $valid_from = mysql_real_escape_string($info['valid_from']); |
|
| 123 |
+ $valid_until = mysql_real_escape_string($info['valid_until']); |
|
| 124 |
+ |
|
| 125 |
+ db_query("UPDATE vhosts.certs SET cert='{$cert}', valid_from='{$valid_from}', valid_until='{$valid_until}' WHERE id={$id} LIMIT 1");
|
|
| 126 |
+} |
|
| 127 |
+ |
|
| 128 |
+ |
|
| 115 | 129 |
function delete_cert($id) |
| 116 | 130 |
{
|
| 117 | 131 |
$uid = (int) $_SESSION['userinfo']['uid']; |
| ... | ... |
@@ -0,0 +1,39 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+require_once('certs.php');
|
|
| 4 |
+require_role(ROLE_SYSTEMUSER); |
|
| 5 |
+ |
|
| 6 |
+ |
|
| 7 |
+$section = "vhosts_certs"; |
|
| 8 |
+$title = "Neue Version eines Zertifikats einspielen"; |
|
| 9 |
+ |
|
| 10 |
+$cert = cert_details($_REQUEST['id']); |
|
| 11 |
+ |
|
| 12 |
+output("<h3>Neue Version eines Zertifikats einspielen</h3>
|
|
| 13 |
+<p>Ein bereits vorhandenes Zetifikat können Sie (z.B. wenn es bald abläuft) durch eine neue Version des selben |
|
| 14 |
+Zertifikats ersetzen. Die meisten Zetifizierungsstellen bieten diese Funktion an, ohne dass ein neuer CSR erzeugt |
|
| 15 |
+werden muss.</p> |
|
| 16 |
+ |
|
| 17 |
+<p>Bitte stellen Sie sicher, dass es sich um das richtige Zertifikat handelt. Das bisherige Zertifikat wurde |
|
| 18 |
+ausgestellt als <strong>{$cert['subject']}</strong>. Nur das dazu passende Zertifikat wird akzeptiert.</p>
|
|
| 19 |
+ |
|
| 20 |
+<p>Wenn die Überprüfung erfolgreich verläuft, wird das alte Zertifikat in unserer Datenbank durch die neue |
|
| 21 |
+Version ersetzt. Der private Schlüssel bleibt erhalten."); |
|
| 22 |
+ |
|
| 23 |
+$form = ' |
|
| 24 |
+<h4>neues Zertifikat:</h4> |
|
| 25 |
+<p><textarea name="cert" rows="10" cols="70"></textarea></p> |
|
| 26 |
+ |
|
| 27 |
+<p><input type="submit" value="Speichern" /></p> |
|
| 28 |
+ |
|
| 29 |
+'; |
|
| 30 |
+ |
|
| 31 |
+output(html_form('vhosts_certs_refresh', 'savecert', 'action=refresh&id='.$cert['id'], $form));
|
|
| 32 |
+ |
|
| 33 |
+ |
|
| 34 |
+ |
|
| 35 |
+ |
|
| 36 |
+ |
|
| 37 |
+ |
|
| 38 |
+ |
|
| 39 |
+ |
| ... | ... |
@@ -24,7 +24,7 @@ if ($_GET['action'] == 'new') |
| 24 | 24 |
{
|
| 25 | 25 |
case CERT_OK: |
| 26 | 26 |
$certinfo = parse_cert_details($cert); |
| 27 |
- save_cert($certinfo, $cert, $key, $cabundle); |
|
| 27 |
+ save_cert($certinfo, $cert, $key); |
|
| 28 | 28 |
if (isset($_REQUEST['csr'])) |
| 29 | 29 |
delete_csr($_REQUEST['csr']); |
| 30 | 30 |
header('Location: certs');
|
| ... | ... |
@@ -43,6 +43,44 @@ if ($_GET['action'] == 'new') |
| 43 | 43 |
break; |
| 44 | 44 |
} |
| 45 | 45 |
|
| 46 |
+} |
|
| 47 |
+elseif ($_GET['action'] == 'refresh') |
|
| 48 |
+{
|
|
| 49 |
+ check_form_token('vhosts_certs_refresh');
|
|
| 50 |
+ $cert = $_POST['cert']; |
|
| 51 |
+ $oldcert = cert_details($_REQUEST['id']); |
|
| 52 |
+ $key = $oldcert['key']; |
|
| 53 |
+ $id = (int) $_REQUEST['id']; |
|
| 54 |
+ |
|
| 55 |
+ if (! $cert ) |
|
| 56 |
+ system_failure('Es muss ein Zertifikat eingetragen werden');
|
|
| 57 |
+ |
|
| 58 |
+ $result = validate_certificate($cert, $key); |
|
| 59 |
+ switch ($result) |
|
| 60 |
+ {
|
|
| 61 |
+ case CERT_OK: |
|
| 62 |
+ $certinfo = parse_cert_details($cert); |
|
| 63 |
+ if ($certinfo['cn'] != $oldcert['cn']) |
|
| 64 |
+ system_failure("Das neue Zertifikat enthält abweichende Daten. Legen Sie bitte ein neues Zertifikat an.");
|
|
| 65 |
+ |
|
| 66 |
+ refresh_cert($id, $certinfo, $cert); |
|
| 67 |
+ header('Location: certs');
|
|
| 68 |
+ die(); |
|
| 69 |
+ break; |
|
| 70 |
+ case CERT_INVALID: |
|
| 71 |
+ system_failure("Das Zertifikat konnte nicht gelesen werden. Eventuell ist es nicht wirklich eine neue Version des bisherigen Zertifikats.");
|
|
| 72 |
+ break; |
|
| 73 |
+ case CERT_NOCHAIN: |
|
| 74 |
+ warning('Ihr Zertifikat konnte nicht mit einer Zertifikats-Kette validiert werden. Dies wird zu Problemen beim Betrachten der damit betriebenen Websites führen. Meist liegt dies an einem nicht hinterlegten CA-Bundle. Die Admins können Ihr Zertifikats-Bundle auf dem System eintragen. Das Zertifikat wurde dennoch gespeichert.');
|
|
| 75 |
+ $certinfo = parse_cert_details($cert); |
|
| 76 |
+ if ($certinfo['cn'] != $oldcert['cn']) |
|
| 77 |
+ system_failure("Das neue Zertifikat enthält abweichende Daten. Legen Sie bitte ein neues Zertifikat an.");
|
|
| 78 |
+ |
|
| 79 |
+ refresh_cert($id, $certinfo, $cert); |
|
| 80 |
+ output('<p>'.internal_link('certs', 'Zurück zur Übersicht').'</p>');
|
|
| 81 |
+ break; |
|
| 82 |
+ } |
|
| 83 |
+ |
|
| 46 | 84 |
} |
| 47 | 85 |
elseif ($_GET['action'] == 'delete') |
| 48 | 86 |
{
|
| 49 | 87 |