Skip to content

Commit bff9826

Browse files
author
Till Brehm
committed
Added a check to prevent that password protected ssl keys get saved. Thanks to Timo for finding the issue.
1 parent 2e999fa commit bff9826

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

server/plugins-available/apache2_plugin.inc.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,22 @@ function ssl($event_name, $data) {
369369
$app->dbmaster->query("UPDATE web_domain SET ssl_request = ?, ssl_cert = ?, ssl_key = ? WHERE domain = ?", $ssl_request, $ssl_cert, $ssl_key2, $data['new']['domain']);
370370
$app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']);
371371
}
372+
373+
//* Check that the SSL key is not password protected
374+
if($data["new"]["ssl_action"] == 'save') {
375+
if(stristr($data["new"]["ssl_key"],'Proc-Type: 4,ENCRYPTED')) {
376+
$data["new"]["ssl_action"] = '';
377+
378+
$app->log('SSL Certificate not saved. The SSL key is encrypted.', LOGLEVEL_WARN);
379+
$app->dbmaster->datalogError('SSL Certificate not saved. The SSL key is encrypted.');
380+
381+
/* Update the DB of the (local) Server */
382+
$app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']);
383+
384+
/* Update also the master-DB of the Server-Farm */
385+
$app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']);
386+
}
387+
}
372388

373389
//* Save a SSL certificate to disk
374390
if($data["new"]["ssl_action"] == 'save') {

server/plugins-available/nginx_plugin.inc.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,22 @@ function ssl($event_name, $data) {
219219
$app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']);
220220
}
221221

222+
//* Check that the SSL key is not password protected
223+
if($data["new"]["ssl_action"] == 'save') {
224+
if(stristr($data["new"]["ssl_key"],'Proc-Type: 4,ENCRYPTED')) {
225+
$data["new"]["ssl_action"] = '';
226+
227+
$app->log('SSL Certificate not saved. The SSL key is encrypted.', LOGLEVEL_WARN);
228+
$app->dbmaster->datalogError('SSL Certificate not saved. The SSL key is encrypted.');
229+
230+
/* Update the DB of the (local) Server */
231+
$app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']);
232+
233+
/* Update also the master-DB of the Server-Farm */
234+
$app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']);
235+
}
236+
}
237+
222238
//* Save a SSL certificate to disk
223239
if($data["new"]["ssl_action"] == 'save') {
224240
$this->ssl_certificate_changed = true;

0 commit comments

Comments
 (0)