*space changes only*
This commit is contained in:
parent
9025bcd78c
commit
06313e510a
|
@ -3,18 +3,13 @@
|
||||||
/**
|
/**
|
||||||
* SSL Api of AlternC, used by alternc-api package
|
* SSL Api of AlternC, used by alternc-api package
|
||||||
*/
|
*/
|
||||||
class Alternc_Api_Object_Ssl {
|
class Alternc_Api_Object_Ssl extends Alternc_Api_Legacyobject {
|
||||||
|
|
||||||
const ERR_INVALID_ARGUMENT = 11151901;
|
protected $ssl;
|
||||||
const ERR_ALTERNC_FUNCTION = 11151902;
|
|
||||||
|
|
||||||
function __construct($service) {
|
function __construct($service) {
|
||||||
global $ssl,$cuid;
|
global $ssl;
|
||||||
if (!($service instanceof Alternc_Api_Service)) {
|
parent::__construct($service);
|
||||||
throw new \Exception("Bad argument: service is not an Alternc_Api_Service", self::ERR_INVALID_ARGUMENT);
|
|
||||||
}
|
|
||||||
// We store the global $cuid to AlternC legacy classes
|
|
||||||
$cuid=$service->token->uid;
|
|
||||||
// We use the global $ssl from AlternC legacy classes
|
// We use the global $ssl from AlternC legacy classes
|
||||||
$this->ssl=$ssl;
|
$this->ssl=$ssl;
|
||||||
}
|
}
|
||||||
|
@ -189,14 +184,4 @@ class Alternc_Api_Object_Ssl {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** return a proper Alternc_Api_Response from an error class and error string
|
|
||||||
* from AlternC legacy class
|
|
||||||
*/
|
|
||||||
private function alterncLegacyErrorManager() {
|
|
||||||
global $err;
|
|
||||||
return new Alternc_Api_Response( array("code" => self::ERR_ALTERNC_FUNCTION, "message" => "[".$err->clsid."] ".$err->error) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // class Alternc_Api_Object_Ssl
|
} // class Alternc_Api_Object_Ssl
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
AlternC - Web Hosting System
|
AlternC - Web Hosting System
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
AlternC - Web Hosting System
|
AlternC - Web Hosting System
|
||||||
|
@ -39,8 +40,10 @@ if (!$fqdn && !$fqdnt) {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($fqdnt) $d=$fqdnt;
|
if ($fqdnt)
|
||||||
if ($fqdn) $d=$fqdn;
|
$d = $fqdnt;
|
||||||
|
if ($fqdn)
|
||||||
|
$d = $fqdn;
|
||||||
|
|
||||||
$id = $ssl->new_csr($d);
|
$id = $ssl->new_csr($d);
|
||||||
$error = $err->errstr();
|
$error = $err->errstr();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
AlternC - Web Hosting System
|
AlternC - Web Hosting System
|
||||||
|
|
|
@ -38,12 +38,14 @@ if ( !isset($is_include) ) {
|
||||||
|
|
||||||
if (isset($filter1) && isset($filter2) && isset($filter4) && isset($filter8)) {
|
if (isset($filter1) && isset($filter2) && isset($filter4) && isset($filter8)) {
|
||||||
$filter = $filter1 + $filter2 + $filter4 + $filter8;
|
$filter = $filter1 + $filter2 + $filter4 + $filter8;
|
||||||
if ($filter==0) $filter=null;
|
if ($filter == 0)
|
||||||
|
$filter = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = $ssl->get_list($filter);
|
$r = $ssl->get_list($filter);
|
||||||
|
|
||||||
if (!$error) $error.=$err->errstr();
|
if (!$error)
|
||||||
|
$error.=$err->errstr();
|
||||||
|
|
||||||
$astatus = array(
|
$astatus = array(
|
||||||
$ssl::STATUS_PENDING => _("Pending Certificate"),
|
$ssl::STATUS_PENDING => _("Pending Certificate"),
|
||||||
|
@ -59,7 +61,6 @@ if ($error) {
|
||||||
if ($info) {
|
if ($info) {
|
||||||
echo "<p class=\"alert alert-info\">$info</p>";
|
echo "<p class=\"alert alert-info\">$info</p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<h3><?php __("Your Certificates"); ?></h3>
|
<h3><?php __("Your Certificates"); ?></h3>
|
||||||
|
|
||||||
|
@ -78,13 +79,16 @@ if ($info) {
|
||||||
<tr><th></th><th><?php __("FQDN"); ?></th><th><?php __("Status"); ?></th><th><?php __("Valid From"); ?></th><th><?php __("Valid Until"); ?></th></tr>
|
<tr><th></th><th><?php __("FQDN"); ?></th><th><?php __("Status"); ?></th><th><?php __("Valid From"); ?></th><th><?php __("Valid Until"); ?></th></tr>
|
||||||
<?php
|
<?php
|
||||||
reset($r);
|
reset($r);
|
||||||
while (list($key,$val)=each($r)) { ?>
|
while (list($key, $val) = each($r)) {
|
||||||
|
?>
|
||||||
<tr class="lst">
|
<tr class="lst">
|
||||||
<td><div class="ina edit"><a href="ssl_view.php?id=<?php echo $val["id"] ?>"><?php __("Details"); ?></a></div></td>
|
<td><div class="ina edit"><a href="ssl_view.php?id=<?php echo $val["id"] ?>"><?php __("Details"); ?></a></div></td>
|
||||||
|
|
||||||
<td><?php echo $val["fqdn"]; ?></td>
|
<td><?php echo $val["fqdn"]; ?></td>
|
||||||
<td><?php echo $astatus[$val["status"]];
|
<td><?php echo $astatus[$val["status"]];
|
||||||
if ($val["shared"]) echo " <i>"._("(shared)")."</i>"; ?></td>
|
if ($val["shared"])
|
||||||
|
echo " <i>" . _("(shared)") . "</i>";
|
||||||
|
?></td>
|
||||||
<?php
|
<?php
|
||||||
if ($val["status"] != $ssl::STATUS_PENDING) {
|
if ($val["status"] != $ssl::STATUS_PENDING) {
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -102,7 +102,8 @@ if (isset($error) && $error) {
|
||||||
<td>
|
<td>
|
||||||
<select name="fqdn" id="fqdn" onchange="switchmanual()"<?php if ($fqdnt != "") echo " style=\"display: none\""; ?>>
|
<select name="fqdn" id="fqdn" onchange="switchmanual()"<?php if ($fqdnt != "") echo " style=\"display: none\""; ?>>
|
||||||
<option value=""><?php __("--- Choose here ---"); ?></option>
|
<option value=""><?php __("--- Choose here ---"); ?></option>
|
||||||
<?php foreach($advice as $a) {
|
<?php
|
||||||
|
foreach ($advice as $a) {
|
||||||
echo "<option>" . $a . "</option>";
|
echo "<option>" . $a . "</option>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
AlternC - Web Hosting System
|
AlternC - Web Hosting System
|
||||||
|
|
|
@ -66,7 +66,8 @@ if ($cert["status"]==$ssl::STATUS_PENDING) {
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><label for="csr"><?php __("Certificate Request File"); ?></label></th>
|
<th><label for="csr"><?php __("Certificate Request File"); ?></label></th>
|
||||||
<td><textarea readonly="readonly" onclick="this.focus();this.select()" class="int cert" name="csr" id="csr" style="width: 500px; height: 120px;"><?php echo $cert["sslcsr"]; ?></textarea></td>
|
<td><textarea readonly="readonly" onclick="this.focus();
|
||||||
|
this.select()" class="int cert" name="csr" id="csr" style="width: 500px; height: 120px;"><?php echo $cert["sslcsr"]; ?></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><label for="crt"><?php __("SSL Certificate"); ?></label></th>
|
<th><label for="crt"><?php __("SSL Certificate"); ?></label></th>
|
||||||
|
@ -85,9 +86,7 @@ if ($cert["status"]==$ssl::STATUS_PENDING) {
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else {
|
|
||||||
|
|
||||||
if ($cert["status"] == $ssl::STATUS_OK) {
|
if ($cert["status"] == $ssl::STATUS_OK) {
|
||||||
?>
|
?>
|
||||||
|
@ -110,7 +109,8 @@ if ($cert["status"]==$ssl::STATUS_EXPIRED) {
|
||||||
<table border="1" cellspacing="0" cellpadding="4" class="tedit">
|
<table border="1" cellspacing="0" cellpadding="4" class="tedit">
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php __("Valid From:"); ?></th>
|
<th><?php __("Valid From:"); ?></th>
|
||||||
<td><?php echo format_date(_('%3$d-%2$d-%1$d %4$d:%5$d'),date("Y-m-d H:i:s",$cert["validstartts"]));
|
<td><?php
|
||||||
|
echo format_date(_('%3$d-%2$d-%1$d %4$d:%5$d'), date("Y-m-d H:i:s", $cert["validstartts"]));
|
||||||
echo " ";
|
echo " ";
|
||||||
$days = intval((time() - $cert["validstartts"]) / 86400);
|
$days = intval((time() - $cert["validstartts"]) / 86400);
|
||||||
if ($days < 60) {
|
if ($days < 60) {
|
||||||
|
@ -123,7 +123,8 @@ if ($days<60) {
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php __("Valid Until:"); ?></th>
|
<th><?php __("Valid Until:"); ?></th>
|
||||||
<td><?php echo format_date(_('%3$d-%2$d-%1$d %4$d:%5$d'),date("Y-m-d H:i:s",$cert["validendts"]));
|
<td><?php
|
||||||
|
echo format_date(_('%3$d-%2$d-%1$d %4$d:%5$d'), date("Y-m-d H:i:s", $cert["validendts"]));
|
||||||
echo " ";
|
echo " ";
|
||||||
$days = intval(($cert["validendts"] - time()) / 86400);
|
$days = intval(($cert["validendts"] - time()) / 86400);
|
||||||
if ($days < 60) {
|
if ($days < 60) {
|
||||||
|
@ -145,19 +146,21 @@ if ($days<60) {
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th><label for="csr"><?php __("Certificate Request File"); ?></label></th>
|
<th><label for="csr"><?php __("Certificate Request File"); ?></label></th>
|
||||||
<td><textarea readonly="readonly" onclick="this.focus();this.select()" class="int cert" name="csr" id="csr" style="width: 500px; height: 120px;"><?php echo $cert["sslcsr"]; ?></textarea></td>
|
<td><textarea readonly="readonly" onclick="this.focus();
|
||||||
|
this.select()" class="int cert" name="csr" id="csr" style="width: 500px; height: 120px;"><?php echo $cert["sslcsr"]; ?></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><label for="crt"><?php __("SSL Certificate"); ?></label></th>
|
<th><label for="crt"><?php __("SSL Certificate"); ?></label></th>
|
||||||
<td><textarea readonly="readonly" onclick="this.focus();this.select()" class="int cert" name="crt" id="crt" style="width: 500px; height: 120px;"><?php echo $cert["sslcrt"]; ?></textarea></td>
|
<td><textarea readonly="readonly" onclick="this.focus();
|
||||||
|
this.select()" class="int cert" name="crt" id="crt" style="width: 500px; height: 120px;"><?php echo $cert["sslcrt"]; ?></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><label for="chain"><?php __("Chained Certificate<br />(not mandatory)"); ?></label></th>
|
<th><label for="chain"><?php __("Chained Certificate<br />(not mandatory)"); ?></label></th>
|
||||||
<td><textarea readonly="readonly" onclick="this.focus();this.select()" class="int cert" name="chain" id="chain" style="width: 500px; height: 120px;"><?php echo $cert["sslchain"]; ?></textarea></td>
|
<td><textarea readonly="readonly" onclick="this.focus();
|
||||||
|
this.select()" class="int cert" name="chain" id="chain" style="width: 500px; height: 120px;"><?php echo $cert["sslchain"]; ?></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// The admin is allowed to share (or not share) his valid certificates
|
// The admin is allowed to share (or not share) his valid certificates
|
||||||
if ($admin->enabled) {
|
if ($admin->enabled) {
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
AlternC - Web Hosting System
|
AlternC - Web Hosting System
|
||||||
|
@ -23,8 +24,7 @@
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/**
|
/**
|
||||||
* SSL Certificates management class
|
* SSL Certificates management class
|
||||||
*/
|
*/
|
||||||
|
@ -33,6 +33,7 @@ class m_ssl {
|
||||||
const STATUS_PENDING = 0; // we have a key / csr, but no CRT
|
const STATUS_PENDING = 0; // we have a key / csr, but no CRT
|
||||||
const STATUS_OK = 1; // we have the key, csr, crt, chain
|
const STATUS_OK = 1; // we have the key, csr, crt, chain
|
||||||
const STATUS_EXPIRED = 99; // The certificate is now expired.
|
const STATUS_EXPIRED = 99; // The certificate is now expired.
|
||||||
|
|
||||||
public $error = "";
|
public $error = "";
|
||||||
|
|
||||||
// Includes one or more of those flags to see only those certificates
|
// Includes one or more of those flags to see only those certificates
|
||||||
|
@ -41,18 +42,17 @@ class m_ssl {
|
||||||
const FILTER_OK = 2;
|
const FILTER_OK = 2;
|
||||||
const FILTER_EXPIRED = 4;
|
const FILTER_EXPIRED = 4;
|
||||||
const FILTER_SHARED = 8;
|
const FILTER_SHARED = 8;
|
||||||
|
|
||||||
const SSL_INCRON_FILE = "/var/run/alternc/ssl/generate_certif_alias";
|
const SSL_INCRON_FILE = "/var/run/alternc/ssl/generate_certif_alias";
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
// -----------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
function m_ssl() {
|
function m_ssl() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/**
|
/**
|
||||||
* Hook to add the "ssl certificate" menu in the Panel
|
* Hook to add the "ssl certificate" menu in the Panel
|
||||||
*/
|
*/
|
||||||
|
@ -70,8 +70,7 @@ class m_ssl {
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($quota->cancreate("ssl")) {
|
if ($quota->cancreate("ssl")) {
|
||||||
$obj['links'][] =
|
$obj['links'][] = array(
|
||||||
array (
|
|
||||||
'ico' => 'images/new.png',
|
'ico' => 'images/new.png',
|
||||||
'txt' => _("New SSL certificate"),
|
'txt' => _("New SSL certificate"),
|
||||||
'url' => "ssl_new.php",
|
'url' => "ssl_new.php",
|
||||||
|
@ -86,8 +85,7 @@ class m_ssl {
|
||||||
$used = $db->f("cnt");
|
$used = $db->f("cnt");
|
||||||
}
|
}
|
||||||
if ($used > 0) { // if there are some SSL certificates
|
if ($used > 0) { // if there are some SSL certificates
|
||||||
$obj['links'][] =
|
$obj['links'][] = array(
|
||||||
array (
|
|
||||||
'txt' => _("List SSL Certificates"),
|
'txt' => _("List SSL Certificates"),
|
||||||
'url' => "ssl_list.php"
|
'url' => "ssl_list.php"
|
||||||
);
|
);
|
||||||
|
@ -96,9 +94,7 @@ class m_ssl {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Return all the SSL certificates for an account (or the searched one)
|
/** Return all the SSL certificates for an account (or the searched one)
|
||||||
* @param $filter an integer telling which certificate we want to see (see FILTER_* constants above)
|
* @param $filter an integer telling which certificate we want to see (see FILTER_* constants above)
|
||||||
* the default is showing all certificate, but only Pending and OK certificates, not expired or shared one
|
* the default is showing all certificate, but only Pending and OK certificates, not expired or shared one
|
||||||
|
@ -130,9 +126,12 @@ class m_ssl {
|
||||||
$sql = " uid='$cuid' ";
|
$sql = " uid='$cuid' ";
|
||||||
}
|
}
|
||||||
$sql.=" AND status IN (-1";
|
$sql.=" AND status IN (-1";
|
||||||
if ($filter & self::FILTER_PENDING) $sql.=",".self::STATUS_PENDING;
|
if ($filter & self::FILTER_PENDING)
|
||||||
if ($filter & self::FILTER_OK) $sql.=",".self::STATUS_OK;
|
$sql.="," . self::STATUS_PENDING;
|
||||||
if ($filter & self::FILTER_EXPIRED) $sql.=",".self::STATUS_EXPIRED;
|
if ($filter & self::FILTER_OK)
|
||||||
|
$sql.="," . self::STATUS_OK;
|
||||||
|
if ($filter & self::FILTER_EXPIRED)
|
||||||
|
$sql.="," . self::STATUS_EXPIRED;
|
||||||
$sql.=") ";
|
$sql.=") ";
|
||||||
$db->query("SELECT *, UNIX_TIMESTAMP(validstart) AS validstartts, UNIX_TIMESTAMP(validend) AS validendts FROM certificates WHERE $sql ORDER BY shared, fqdn;");
|
$db->query("SELECT *, UNIX_TIMESTAMP(validstart) AS validstartts, UNIX_TIMESTAMP(validend) AS validendts FROM certificates WHERE $sql ORDER BY shared, fqdn;");
|
||||||
if ($db->num_rows()) {
|
if ($db->num_rows()) {
|
||||||
|
@ -146,8 +145,7 @@ class m_ssl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Generate a new CSR, a new Private RSA Key, for FQDN.
|
/** Generate a new CSR, a new Private RSA Key, for FQDN.
|
||||||
* @param $fqdn string the FQDN of the domain name for which we want a CSR.
|
* @param $fqdn string the FQDN of the domain name for which we want a CSR.
|
||||||
* a wildcard certificate must start by *.
|
* a wildcard certificate must start by *.
|
||||||
|
@ -189,8 +187,7 @@ class m_ssl {
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Return all informations of a given certificate for the current user.
|
/** Return all informations of a given certificate for the current user.
|
||||||
* @return array all the informations of the current certificate as a hash.
|
* @return array all the informations of the current certificate as a hash.
|
||||||
*/
|
*/
|
||||||
|
@ -206,8 +203,7 @@ class m_ssl {
|
||||||
return $db->Record;
|
return $db->Record;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Share (or unshare) an ssl certificate
|
/** Share (or unshare) an ssl certificate
|
||||||
* @param $id integer the id of the certificate in the table.
|
* @param $id integer the id of the certificate in the table.
|
||||||
* @param $action integer share (1) or unshare (0) this certificate
|
* @param $action integer share (1) or unshare (0) this certificate
|
||||||
|
@ -222,13 +218,15 @@ class m_ssl {
|
||||||
$err->raise("ssl", _("Can't find this Certifcate"));
|
$err->raise("ssl", _("Can't find this Certifcate"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($action) $action=1; else $action=0;
|
if ($action)
|
||||||
|
$action = 1;
|
||||||
|
else
|
||||||
|
$action = 0;
|
||||||
$db->query("UPDATE certificates SET shared=$action WHERE id='$id';");
|
$db->query("UPDATE certificates SET shared=$action WHERE id='$id';");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Return all the subdomains that can be ssl-enabled for the current account.
|
/** Return all the subdomains that can be ssl-enabled for the current account.
|
||||||
* @return array of strings : all the subdomains.
|
* @return array of strings : all the subdomains.
|
||||||
* Excludes the one for which a cert is already available
|
* Excludes the one for which a cert is already available
|
||||||
|
@ -251,7 +249,8 @@ class m_ssl {
|
||||||
$advice = array();
|
$advice = array();
|
||||||
while ($db->next_record()) {
|
while ($db->next_record()) {
|
||||||
$me = $db->f("sub");
|
$me = $db->f("sub");
|
||||||
if ($me) $me.=".";
|
if ($me)
|
||||||
|
$me.=".";
|
||||||
$me.=$db->f("domaine");
|
$me.=$db->f("domaine");
|
||||||
if (!in_array($me, $r) && !in_array($me, $advice)) {
|
if (!in_array($me, $r) && !in_array($me, $advice)) {
|
||||||
$advice[] = $me;
|
$advice[] = $me;
|
||||||
|
@ -264,8 +263,7 @@ class m_ssl {
|
||||||
return($advice);
|
return($advice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Import an existing ssl Key, Certificate and (maybe) a Chained Cert
|
/** Import an existing ssl Key, Certificate and (maybe) a Chained Cert
|
||||||
* @param $key string the X.509 PEM-encoded RSA key
|
* @param $key string the X.509 PEM-encoded RSA key
|
||||||
* @param $crt string the X.509 PEM-encoded certificate, which *must*
|
* @param $crt string the X.509 PEM-encoded certificate, which *must*
|
||||||
|
@ -300,8 +298,7 @@ class m_ssl {
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Import an ssl certificate into an existing certificate entry in the DB.
|
/** Import an ssl certificate into an existing certificate entry in the DB.
|
||||||
* (finalize an enrollment process)
|
* (finalize an enrollment process)
|
||||||
* @param $certid integer the ID in the database of the SSL Certificate
|
* @param $certid integer the ID in the database of the SSL Certificate
|
||||||
|
@ -337,8 +334,7 @@ class m_ssl {
|
||||||
return $certid;
|
return $certid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Function called by a hook when an AlternC member is deleted.
|
/** Function called by a hook when an AlternC member is deleted.
|
||||||
* @access private
|
* @access private
|
||||||
* TODO: delete unused ssl certificates ?? > do this in the crontab.
|
* TODO: delete unused ssl certificates ?? > do this in the crontab.
|
||||||
|
@ -350,8 +346,7 @@ class m_ssl {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Hook which returns the used quota for the $name service for the current user.
|
/** Hook which returns the used quota for the $name service for the current user.
|
||||||
* @param $name string name of the quota
|
* @param $name string name of the quota
|
||||||
* @return integer the number of service used or false if an error occured
|
* @return integer the number of service used or false if an error occured
|
||||||
|
@ -368,8 +363,7 @@ class m_ssl {
|
||||||
return $q;
|
return $q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Export every information for an AlternC's account
|
/** Export every information for an AlternC's account
|
||||||
* @access private
|
* @access private
|
||||||
* EXPERIMENTAL 'sid' function ;)
|
* EXPERIMENTAL 'sid' function ;)
|
||||||
|
@ -391,8 +385,7 @@ class m_ssl {
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Returns the list of alternate names of an X.509 SSL Certificate
|
/** Returns the list of alternate names of an X.509 SSL Certificate
|
||||||
* from the attribute list.
|
* from the attribute list.
|
||||||
* @param $str string the $crtdata["extensions"]["subjectAltName"] from openssl
|
* @param $str string the $crtdata["extensions"]["subjectAltName"] from openssl
|
||||||
|
@ -406,8 +399,7 @@ class m_ssl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Add (immediately) a global alias to the HTTP
|
/** Add (immediately) a global alias to the HTTP
|
||||||
* certif_alias table and add it to apache configuration
|
* certif_alias table and add it to apache configuration
|
||||||
* by launching a incron action.
|
* by launching a incron action.
|
||||||
|
@ -429,8 +421,7 @@ class m_ssl {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Removes (immediately) a global alias to the HTTP
|
/** Removes (immediately) a global alias to the HTTP
|
||||||
* certif_alias table and add it to apache configuration
|
* certif_alias table and add it to apache configuration
|
||||||
* by launching a incron action.
|
* by launching a incron action.
|
||||||
|
@ -449,8 +440,7 @@ class m_ssl {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Check that a crt is a proper certificate
|
/** Check that a crt is a proper certificate
|
||||||
* @param $crt string an SSL Certificate
|
* @param $crt string an SSL Certificate
|
||||||
* @param $chain string is a list of certificates
|
* @param $chain string is a list of certificates
|
||||||
|
@ -490,8 +480,7 @@ class m_ssl {
|
||||||
if ((substr($key, 0, 32) != "-----BEGIN RSA PRIVATE KEY-----\n" ||
|
if ((substr($key, 0, 32) != "-----BEGIN RSA PRIVATE KEY-----\n" ||
|
||||||
substr($key, -30, 30) != "-----END RSA PRIVATE KEY-----\n") &&
|
substr($key, -30, 30) != "-----END RSA PRIVATE KEY-----\n") &&
|
||||||
(substr($key, 0, 28) != "-----BEGIN PRIVATE KEY-----\n" ||
|
(substr($key, 0, 28) != "-----BEGIN PRIVATE KEY-----\n" ||
|
||||||
substr($key,-26,26)!="-----END PRIVATE KEY-----\n") )
|
substr($key, -26, 26) != "-----END PRIVATE KEY-----\n")) {
|
||||||
{
|
|
||||||
$this->error.=_("The private key must begin by BEGIN (RSA )PRIVATE KEY and end by END (RSA )PRIVATE KEY lines. Please check you pasted it in PEM form.") . "\n";
|
$this->error.=_("The private key must begin by BEGIN (RSA )PRIVATE KEY and end by END (RSA )PRIVATE KEY lines. Please check you pasted it in PEM form.") . "\n";
|
||||||
}
|
}
|
||||||
if ($this->error) {
|
if ($this->error) {
|
||||||
|
@ -500,7 +489,8 @@ class m_ssl {
|
||||||
|
|
||||||
// We split the chained certificates in individuals certificates :
|
// We split the chained certificates in individuals certificates :
|
||||||
$chains = array();
|
$chains = array();
|
||||||
$status=0; $new="";
|
$status = 0;
|
||||||
|
$new = "";
|
||||||
$lines = explode("\n", $chain);
|
$lines = explode("\n", $chain);
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
if ($line == "-----BEGIN CERTIFICATE-----" && $status == 0) {
|
if ($line == "-----BEGIN CERTIFICATE-----" && $status == 0) {
|
||||||
|
@ -521,7 +511,8 @@ class m_ssl {
|
||||||
}
|
}
|
||||||
// here chains contains all the ssl certificates in the chained certs.
|
// here chains contains all the ssl certificates in the chained certs.
|
||||||
// Now we check those using Openssl functions (real check :) )
|
// Now we check those using Openssl functions (real check :) )
|
||||||
$rchains=array(); $i=0;
|
$rchains = array();
|
||||||
|
$i = 0;
|
||||||
foreach ($chains as $tmpcert) {
|
foreach ($chains as $tmpcert) {
|
||||||
$i++;
|
$i++;
|
||||||
$tmpr = openssl_x509_read($tmpcert);
|
$tmpr = openssl_x509_read($tmpcert);
|
||||||
|
@ -531,7 +522,8 @@ class m_ssl {
|
||||||
$rchains[] = $tmpr;
|
$rchains[] = $tmpr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$validstart=0; $validend=0;
|
$validstart = 0;
|
||||||
|
$validend = 0;
|
||||||
$rcrt = openssl_x509_read($crt);
|
$rcrt = openssl_x509_read($crt);
|
||||||
$crtdata = openssl_x509_parse($crt);
|
$crtdata = openssl_x509_parse($crt);
|
||||||
if ($rcrt === false || $crtdata === false) {
|
if ($rcrt === false || $crtdata === false) {
|
||||||
|
@ -566,8 +558,10 @@ class m_ssl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array($crt, $chain, $key, $crtdata);
|
return array($crt, $chain, $key, $crtdata);
|
||||||
} // check_cert
|
}
|
||||||
|
|
||||||
|
// check_cert
|
||||||
|
}
|
||||||
|
|
||||||
} /* Class m_ssl */
|
/* Class m_ssl */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue