[fix] we check FIRST for certificate already existing in ssl->import_check()
This commit is contained in:
parent
152551a8bb
commit
a2e22a8d1f
|
@ -457,6 +457,13 @@ INSTR(CONCAT(sd.sub,IF(sd.sub!='','.',''),sd.domaine),'.')+1))=?
|
||||||
global $cuid, $msg, $db;
|
global $cuid, $msg, $db;
|
||||||
$msg->log("ssl", "import_cert");
|
$msg->log("ssl", "import_cert");
|
||||||
|
|
||||||
|
// Search for an existing cert: (first)
|
||||||
|
$db->query("SELECT id FROM certificates WHERE crt=?;",array($crt));
|
||||||
|
if ($db->next_record()) {
|
||||||
|
$msg->raise("ERROR","ssl", _("Certificate already exists in database"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$result = $this->check_cert($crt, $chain, $key);
|
$result = $this->check_cert($crt, $chain, $key);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
$msg->raise("ERROR","ssl", $this->error);
|
$msg->raise("ERROR","ssl", $this->error);
|
||||||
|
@ -469,13 +476,6 @@ INSTR(CONCAT(sd.sub,IF(sd.sub!='','.',''),sd.domaine),'.')+1))=?
|
||||||
$fqdn = $crtdata["subject"]["CN"];
|
$fqdn = $crtdata["subject"]["CN"];
|
||||||
$altnames = $this->parseAltNames($crtdata["extensions"]["subjectAltName"]);
|
$altnames = $this->parseAltNames($crtdata["extensions"]["subjectAltName"]);
|
||||||
|
|
||||||
// Search for an existing cert:
|
|
||||||
$db->query("SELECT id FROM certificates WHERE crt=?;",array($crt));
|
|
||||||
if ($db->next_record()) {
|
|
||||||
$msg->raise("ERROR","ssl", _("Certificate already exists in database"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Everything is PERFECT and has been thoroughly checked, let's insert those in the DB !
|
// Everything is PERFECT and has been thoroughly checked, let's insert those in the DB !
|
||||||
$db->query(
|
$db->query(
|
||||||
"INSERT INTO certificates SET uid='?', status=?, shared=0, fqdn=?, altnames=?, validstart=FROM_UNIXTIME(?), validend=FROM_UNIXTIME(?), sslkey=?, sslcrt=?, sslchain=?, provider=?;",
|
"INSERT INTO certificates SET uid='?', status=?, shared=0, fqdn=?, altnames=?, validstart=FROM_UNIXTIME(?), validend=FROM_UNIXTIME(?), sslkey=?, sslcrt=?, sslchain=?, provider=?;",
|
||||||
|
|
Loading…
Reference in New Issue