Browse code

zertifikate und keys exportieren um datenm├╝ll zu vermeiden

git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1454 87cf0b9e-d624-0410-a070-f6ee81989793

hanno authored on04/09/2009 19:02:40
Showing1 changed files
... ...
@@ -101,6 +101,8 @@ validTo_time_t => 1267190790
101 101
 
102 102
 function save_cert($info, $cert, $key)
103 103
 {
104
+  openssl_pkey_export($key, $key);
105
+  openssl_x509_export($cert, $cert);
104 106
   $subject = mysql_real_escape_string(filter_input_general($info['subject']));
105 107
   $cn = mysql_real_escape_string(filter_input_general($info['cn']));
106 108
   $valid_from = mysql_real_escape_string($info['valid_from']);
... ...
@@ -115,6 +117,7 @@ function save_cert($info, $cert, $key)
115 117
 
116 118
 function refresh_cert($id, $info, $cert, $key = NULL)
117 119
 {
120
+  openssl_x509_export($cert, $cert);
118 121
   $id = (int) $id;
119 122
   $oldcert = cert_details($id);
120 123
   $cert = mysql_real_escape_string($cert);
... ...
@@ -123,8 +126,10 @@ function refresh_cert($id, $info, $cert, $key = NULL)
123 126
   $valid_until = mysql_real_escape_string($info['valid_until']);
124 127
 
125 128
   $keyop = '';
126
-  if ($key)
129
+  if ($key) {
130
+    openssl_pkey_export($key, $key);
127 131
     $keyop = ", `key`='".mysql_real_escape_string($key)."'";
132
+  }
128 133
   db_query("UPDATE vhosts.certs SET cert='{$cert}'{$keyop}, valid_from='{$valid_from}', valid_until='{$valid_until}' WHERE id={$id} LIMIT 1");
129 134
 }
130 135