Bernd Wurst commited on 2013-03-10 18:57:34
Zeige 4 geänderte Dateien mit 6 Einfügungen und 74 Löschungen.
| ... | ... |
@@ -95,6 +95,7 @@ function filter_input_hostname( $input, $wildcard=false ) |
| 95 | 95 |
{
|
| 96 | 96 |
// FIXME: Eine "filter"-Funktion sollte keinen system_failure verursachen sondern einfach einen bereinigten String liefern. |
| 97 | 97 |
|
| 98 |
+ DEBUG('filter_input_hostname("'.$input.'", $wildcard='.$wildcard.')');
|
|
| 98 | 99 |
$input = str_replace(array('Ä', 'Ö', 'Ü'), array('ä', 'ö', 'ü'), strtolower($input));
|
| 99 | 100 |
$input = rtrim($input, "\t\n\r\x00 ."); |
| 100 | 101 |
$input = ltrim($input, "\t\n\r\x00 ."); |
| ... | ... |
@@ -235,71 +235,10 @@ function delete_csr($id) |
| 235 | 235 |
db_query("DELETE FROM vhosts.csr WHERE uid={$uid} AND id={$id} LIMIT 1");
|
| 236 | 236 |
} |
| 237 | 237 |
|
| 238 |
-function create_wildcard_csr($cn, $bits) |
|
| 239 |
-{
|
|
| 240 |
- $cn = filter_input_hostname($cn); |
|
| 241 |
- $bits = (int) $bits; |
|
| 242 |
- if ($bits == 0) |
|
| 243 |
- $bits = 4096; |
|
| 244 |
- |
|
| 245 |
- $keyfile = tempnam(ini_get('upload_tmp_dir'), 'key');
|
|
| 246 |
- $csrfile = tempnam(ini_get('upload_tmp_dir'), 'csr');
|
|
| 247 |
- $config = tempnam(ini_get('upload_tmp_dir'), 'config');
|
|
| 248 |
- |
|
| 249 |
- DEBUG("key: ".$keyfile." / csr: ".$csrfile." / config: ".$config);
|
|
| 250 |
- |
|
| 251 |
- $c = fopen($config, "w"); |
|
| 252 |
- fwrite($c, "[req] |
|
| 253 |
-default_bits = {$bits}
|
|
| 254 |
-default_keyfile = {$keyfile}
|
|
| 255 |
-encrypt_key = no |
|
| 256 |
-distinguished_name = req_distinguished_name |
|
| 257 |
-req_extensions = v3_req |
|
| 258 |
- |
|
| 259 |
-[v3_req] |
|
| 260 |
-subjectAltName = DNS:{$cn}, DNS:*.{$cn}
|
|
| 261 |
- |
|
| 262 |
-[ req_distinguished_name ] |
|
| 263 |
-countryName = Country Name (2 letter code) |
|
| 264 |
-countryName_default = DE |
|
| 265 |
-stateOrProvinceName = State or Province Name (full name) |
|
| 266 |
-stateOrProvinceName_default = Baden-Wuerttemberg |
|
| 267 |
-localityName = Locality Name (eg, city) |
|
| 268 |
-localityName_default = Murrhardt |
|
| 269 |
-0.organizationName = Organization Name (eg, company) |
|
| 270 |
-0.organizationName_default = schokokeks.org |
|
| 271 |
- |
|
| 272 |
-commonName = Common Name |
|
| 273 |
-commonName_default = *.{$cn}
|
|
| 274 |
-"); |
|
| 275 |
- fclose($c); |
|
| 276 |
- |
|
| 277 |
- $output = ''; |
|
| 278 |
- $cmdline = "openssl req -sha256 -new -batch -config {$config} -out {$csrfile}";
|
|
| 279 |
- $retval = 0; |
|
| 280 |
- exec($cmdline, $output, $retval); |
|
| 281 |
- DEBUG($output); |
|
| 282 |
- DEBUG($retval); |
|
| 283 |
- if ($retval != 0) |
|
| 284 |
- {
|
|
| 285 |
- system_failure("Die Erzeugung des CSR ist fehlgeschlagen. Ausgabe des OpenSSL-Befehls: ".print_r($output, true));
|
|
| 286 |
- } |
|
| 287 |
- |
|
| 288 |
- $csr = file_get_contents($csrfile); |
|
| 289 |
- $key = file_get_contents($keyfile); |
|
| 290 |
- |
|
| 291 |
- unlink($csrfile); |
|
| 292 |
- unlink($keyfile); |
|
| 293 |
- unlink($config); |
|
| 294 |
- |
|
| 295 |
- return array($csr, $key); |
|
| 296 |
-} |
|
| 297 |
- |
|
| 298 |
- |
|
| 299 | 238 |
|
| 300 | 239 |
function create_csr($cn, $bits) |
| 301 | 240 |
{
|
| 302 |
- $cn = filter_input_hostname($cn); |
|
| 241 |
+ $cn = filter_input_hostname($cn, true); |
|
| 303 | 242 |
$bits = (int) $bits; |
| 304 | 243 |
if ($bits == 0) |
| 305 | 244 |
$bits = 4096; |
| ... | ... |
@@ -355,20 +294,17 @@ commonName_default = {$cn}
|
| 355 | 294 |
|
| 356 | 295 |
|
| 357 | 296 |
|
| 358 |
-function save_csr($cn, $bits, $wildcard=true, $replace=NULL) |
|
| 297 |
+function save_csr($cn, $bits, $replace=NULL) |
|
| 359 | 298 |
{
|
| 360 | 299 |
if (! $cn) {
|
| 361 | 300 |
system_failure("Sie müssen einen Domainname eingeben!");
|
| 362 | 301 |
} |
| 363 | 302 |
$csr = NULL; |
| 364 | 303 |
$key = NULL; |
| 365 |
- if ($wildcard) |
|
| 366 |
- list($csr, $key) = create_wildcard_csr($cn, $bits); |
|
| 367 |
- else |
|
| 368 | 304 |
list($csr, $key) = create_csr($cn, $bits); |
| 369 | 305 |
|
| 370 | 306 |
$uid = (int) $_SESSION['userinfo']['uid']; |
| 371 |
- $cn = mysql_real_escape_string(filter_input_hostname($cn)); |
|
| 307 |
+ $cn = mysql_real_escape_string(filter_input_hostname($cn, true)); |
|
| 372 | 308 |
$bits = (int) $bits; |
| 373 | 309 |
$replace = ($replace ? (int) $replace : 'NULL'); |
| 374 | 310 |
$csr = mysql_real_escape_string($csr); |
| ... | ... |
@@ -31,13 +31,9 @@ Zertifikat zurück.</p> |
| 31 | 31 |
eines CSR festlegen. Insbesondere die Angabe des Inhabers wurde hier entfernt. CAcert (und andere |
| 32 | 32 |
günstige CAs) würde diese Zusatzinformationen sowieso aus dem Zertifikat entfernen. Für eigene |
| 33 | 33 |
Einstellungen stehen Ihnen die OpenSSL-Programme in Ihrem Benutzeraccount zur Verfügung.</p> |
| 34 |
- |
|
| 35 |
-<p>Bei Eingabe einer Domain (»domain.de«) ohne Subdomain (also nicht »www.domain.de«) wird ein |
|
| 36 |
-<strong>Catch-All-Zertifikat</strong> erstellt, das für sämtliche Subdomains genutzt werden kann. Manche kommerziellen |
|
| 37 |
-Zertifikats-Anbieter akzeptieren keine solchen Zertifikate in den günstigen Tarifen.</p> |
|
| 38 | 34 |
"); |
| 39 | 35 |
|
| 40 |
-$bitselect = array(1024 => 1024, 2048 => 2048, 4096 => 4096); |
|
| 36 |
+$bitselect = array(2048 => 2048, 4096 => 4096); |
|
| 41 | 37 |
|
| 42 | 38 |
$form = '<p><label for="commonname">Domain-/Hostname:</label> <input type="text" name="commonname" id="commonname" /></p> |
| 43 | 39 |
<p><label for="bitlength">Bitlänge:</label> '.html_select('bitlength', $bitselect, 4096).'</p>
|
| ... | ... |
@@ -159,8 +159,7 @@ elseif ($_GET['action'] == 'newcsr') |
| 159 | 159 |
$bitlength = $_REQUEST['bitlength']; |
| 160 | 160 |
} |
| 161 | 161 |
|
| 162 |
- $wildcard = ! (count(explode('.', $cn)) > 2);
|
|
| 163 |
- $id = save_csr($cn, $bitlength, $wildcard, $replace); |
|
| 162 |
+ $id = save_csr($cn, $bitlength, $replace); |
|
| 164 | 163 |
|
| 165 | 164 |
header("Location: showcert?mode=csr&id={$id}");
|
| 166 | 165 |
die(); |
| 167 | 166 |