$cert['descr'] = $pconfig['descr']; $old_err_level = error_reporting(0); /* otherwise openssl_ functions throw warings directly to a page screwing menu tab */ if ($pconfig['certmethod'] == "import") { cert_import($cert, $pconfig['cert'], $pconfig['key']); } if ($pconfig['certmethod'] == "internal") { $dn = array('countryName' => $pconfig['dn_country'], 'stateOrProvinceName' => $pconfig['dn_state'], 'localityName' => $pconfig['dn_city'], 'organizationName' => $pconfig['dn_organization'], 'emailAddress' => $pconfig['dn_email'], 'commonName' => $pconfig['dn_commonname']); if (count($altnames)) { $altnames_tmp = ""; foreach ($altnames as $altname) { $altnames_tmp[] = "{$altname['type']}:{$altname['value']}"; } $dn['subjectAltName'] = implode(",", $altnames_tmp); } if (!cert_create($cert, $pconfig['caref'], $pconfig['keylen'], $pconfig['lifetime'], $dn, $pconfig['digest_alg'], $pconfig['cert_type'])) { $input_errors = array(); while ($ssl_err = openssl_error_string()) { $input_errors[] = gettext("openssl library returns:") . " " . $ssl_err; } } } if ($pconfig['certmethod'] == "external") { $dn = array('countryName' => $pconfig['csr_dn_country'], 'stateOrProvinceName' => $pconfig['csr_dn_state'], 'localityName' => $pconfig['csr_dn_city'], 'organizationName' => $pconfig['csr_dn_organization'], 'emailAddress' => $pconfig['csr_dn_email'], 'commonName' => $pconfig['csr_dn_commonname']); if (count($altnames)) { $altnames_tmp = ""; foreach ($altnames as $altname) { $altnames_tmp[] = "{$altname['type']}:{$altname['value']}"; } $dn['subjectAltName'] = implode(",", $altnames_tmp); }
if (!empty($pconfig['disabled'])) { $userent['disabled'] = true; } elseif (isset($userent['disabled'])) { unset($userent['disabled']); } if (isset($id)) { $a_user[$id] = $userent; } else { if (!empty($pconfig['name'])) { $cert = array(); $cert['refid'] = uniqid(); $userent['cert'] = array(); $cert['descr'] = $pconfig['name']; $subject = cert_get_subject_array($ca['crt']); $dn = array('countryName' => $subject[0]['v'], 'stateOrProvinceName' => $subject[1]['v'], 'localityName' => $subject[2]['v'], 'organizationName' => $subject[3]['v'], 'emailAddress' => $subject[4]['v'], 'commonName' => $userent['name']); cert_create($cert, $pconfig['caref'], $pconfig['keylen'], (int) $pconfig['lifetime'], $dn); if (!is_array($config['cert'])) { $config['cert'] = array(); } $config['cert'][] = $cert; $userent['cert'][] = $cert['refid']; } $userent['uid'] = $config['system']['nextuid']++; /* Add the user to All Users group. */ foreach ($config['system']['group'] as $gidx => $group) { if ($group['name'] == "all") { if (!is_array($config['system']['group'][$gidx]['member'])) { $config['system']['group'][$gidx]['member'] = array(); } $config['system']['group'][$gidx]['member'][] = $userent['uid']; break;
if ($_POST['disabled']) { $userent['disabled'] = true; } else { unset($userent['disabled']); } if (isset($id) && $a_user[$id]) { $a_user[$id] = $userent; } else { if (!empty($_POST['name'])) { $cert = array(); $cert['refid'] = uniqid(); $userent['cert'] = array(); $cert['descr'] = $_POST['name']; $subject = cert_get_subject_array($ca['crt']); $dn = array('countryName' => $subject[0]['v'], 'stateOrProvinceName' => $subject[1]['v'], 'localityName' => $subject[2]['v'], 'organizationName' => $subject[3]['v'], 'emailAddress' => $subject[4]['v'], 'commonName' => $userent['name']); cert_create($cert, $_POST['caref'], $_POST['keylen'], (int) $_POST['lifetime'], $dn); if (!is_array($config['cert'])) { $config['cert'] = array(); } $config['cert'][] = $cert; $userent['cert'][] = $cert['refid']; } $userent['uid'] = $config['system']['nextuid']++; /* Add the user to All Users group. */ foreach ($config['system']['group'] as $gidx => $group) { if ($group['name'] == "all") { if (!is_array($config['system']['group'][$gidx]['member'])) { $config['system']['group'][$gidx]['member'] = array(); } $config['system']['group'][$gidx]['member'][] = $userent['uid']; break;
} } else { $cert = array(); $cert['refid'] = uniqid(); if (isset($id) && $a_cert[$id]) { $cert = $a_cert[$id]; } $cert['descr'] = $pconfig['descr']; $old_err_level = error_reporting(0); /* otherwise openssl_ functions throw warings directly to a page screwing menu tab */ if ($pconfig['method'] == "import") { cert_import($cert, $pconfig['cert'], $pconfig['key']); } if ($pconfig['method'] == "internal") { $dn = array('countryName' => $pconfig['dn_country'], 'stateOrProvinceName' => $pconfig['dn_state'], 'localityName' => $pconfig['dn_city'], 'organizationName' => $pconfig['dn_organization'], 'emailAddress' => $pconfig['dn_email'], 'commonName' => $pconfig['dn_commonname']); if (!cert_create($cert, $pconfig['caref'], $pconfig['keylen'], $pconfig['lifetime'], $dn, $pconfig['type'])) { while ($ssl_err = openssl_error_string()) { $input_errors = array(); array_push($input_errors, "openssl library returns: " . $ssl_err); } } } if ($pconfig['method'] == "external") { $dn = array('countryName' => $pconfig['csr_dn_country'], 'stateOrProvinceName' => $pconfig['csr_dn_state'], 'localityName' => $pconfig['csr_dn_city'], 'organizationName' => $pconfig['csr_dn_organization'], 'emailAddress' => $pconfig['csr_dn_email'], 'commonName' => $pconfig['csr_dn_commonname']); if (!csr_generate($cert, $pconfig['csr_keylen'], $dn)) { while ($ssl_err = openssl_error_string()) { $input_errors = array(); array_push($input_errors, "openssl library returns: " . $ssl_err); } } }