From bb6d5c68637a394134222a4fa210e7fcf8c4a96d Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Fri, 12 Jul 2019 14:46:36 -0400 Subject: [PATCH] Fix insert query failure during import_cert The sslcsr is just set to an empty string so that the query works properly. Without it, queries fail since sslcsr does not have a default value set. Improved the detail of the messages logged during the failure of that query as well. --- bureau/class/m_ssl.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bureau/class/m_ssl.php b/bureau/class/m_ssl.php index dcae0c9f..d88855e8 100644 --- a/bureau/class/m_ssl.php +++ b/bureau/class/m_ssl.php @@ -511,11 +511,13 @@ INSTR(CONCAT(sd.sub,IF(sd.sub!='','.',''),sd.domaine),'.')+1))=? $altnames = $this->parseAltNames($crtdata["extensions"]["subjectAltName"]); // Everything is PERFECT and has been thoroughly checked, let's insert those in the DB ! + // The sslcsr column is required as it has no default value, giving it an empty value. $db->query( - "INSERT INTO certificates SET uid=?, status=?, fqdn=?, altnames=?, validstart=FROM_UNIXTIME(?), validend=FROM_UNIXTIME(?), sslkey=?, sslcrt=?, sslchain=?, provider=?;", + "INSERT INTO certificates SET uid=?, status=?, fqdn=?, altnames=?, validstart=FROM_UNIXTIME(?), validend=FROM_UNIXTIME(?), sslkey=?, sslcrt=?, sslchain=?, provider=?, sslcsr = '';", array($cuid, self::STATUS_OK, $fqdn, $altnames, intval($validstart), intval($validend), $key, $crt, $chain, $provider) ); if (!($id = $db->lastid())) { + $msg->log('ssl', 'impoert_cert', 'insert query failed (' . print_r($db->last_error(), TRUE) . ')'); $msg->raise("ERROR","ssl", _("Can't save the Key/Crt/Chain now. Please try later.")); return false; }