From 90489cf59ab961814da4b417e070873372450a3c Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Thu, 31 Jan 2013 05:55:59 -0500
Subject: [PATCH] Fixed: FS#2629 - SSL Key field empty after upgrade from 3.0.4 to 3.0.5

---
 server/plugins-available/apache2_plugin.inc.php |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index 42b9c63..6ed7181 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -243,7 +243,17 @@
 			if(trim($data["new"]["ssl_request"]) != '') $app->system->file_put_contents($csr_file,$data["new"]["ssl_request"]);
 			if(trim($data["new"]["ssl_cert"]) != '') $app->system->file_put_contents($crt_file,$data["new"]["ssl_cert"]);
 			if(trim($data["new"]["ssl_bundle"]) != '') $app->system->file_put_contents($bundle_file,$data["new"]["ssl_bundle"]);
-			if(trim($data["new"]["ssl_key"]) != '') $app->system->file_put_contents($key_file2,$data["new"]["ssl_key"]);
+			
+			//* Write the key file, if field is empty then import the key into the db
+			if(trim($data["new"]["ssl_key"]) != '') {
+				$app->system->file_put_contents($key_file2,$data["new"]["ssl_key"]);
+			} else {
+				$ssl_key2 = $app->db->quote($app->system->file_get_contents($key_file2));
+				/* Update the DB of the (local) Server */
+				$app->db->query("UPDATE web_domain SET ssl_key = '$ssl_key2' WHERE domain = '".$data['new']['domain']."'");
+				/* Update also the master-DB of the Server-Farm */
+				$app->dbmaster->query("UPDATE web_domain SET ssl_key = '$ssl_key2' WHERE domain = '".$data['new']['domain']."'");
+			}
 			
 			/* Update the DB of the (local) Server */
 			$app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'");

--
Gitblit v1.9.1