Commit fb68c5c7 authored by Adrian Rossouw's avatar Adrian Rossouw

SSL WORKS NOW! ... Added a copy method to the file class, amazed we didnt have one before.

parent b40114e6
......@@ -74,8 +74,6 @@ class provisionConfig_http_server extends provisionConfig_http {
}
/**
* Base class for platform configuration files.
*/
......
......@@ -37,12 +37,12 @@ class provisionService_http_ssl extends provisionService_http_public {
function config_data($config = null, $class = null) {
$data = parent::config_data($config, $class);
$data['http_ssl_port'] = $this->server->http_ssl_port;
if ($config == 'site' && $this->context->ssl_enabled) {
if ($ssl_key = $this->context->ssl_key) {
// Retrieve the paths to the cert and key files.
// they are generated if not found.
$certs = $this->get_certificates($ssl_key);
$data = array_merge($data, $certs);
......@@ -50,6 +50,7 @@ class provisionService_http_ssl extends provisionService_http_public {
$data['ip_address'] = $this->server->ip_addresses[0];
}
}
return $data;
}
......@@ -66,7 +67,7 @@ class provisionService_http_ssl extends provisionService_http_public {
$certs['ssl_cert_source'] = "{$source_path}/openssl.crt";
foreach ($certs as $cert) {
$exists = provision_file()->exists($cert).status();
$exists = provision_file()->exists($cert)->status();
if (!$exists) {
// if any of the files don't exist, regenerate them.
$this->generate_certificates($ssl_key);
......@@ -79,7 +80,7 @@ class provisionService_http_ssl extends provisionService_http_public {
$path = "{$this->server->http_ssld_path}/{$ssl_key}";
$certs['ssl_cert_key'] = "{$path}/openssl.key";
$certs['ssl_cert'] = "{$path}/openssl.crt";
return $certs;
}
......@@ -93,12 +94,12 @@ class provisionService_http_ssl extends provisionService_http_public {
function generate_certificates($ssl_key) {
$path = "{$this->server->ssld_path}/{$ssl_key}";
$created = provision_file()->create_dir($path,
provision_file()->create_dir($path,
dt("SSL certificate directory for %ssl_key", array(
'%ssl_key' => $ssl_key
)), 0700)->status();
)), 0700);
if ($created) {
if (provision_file()->exists($path)->status()) {
$pass = 'pass';
// generate a key
......@@ -177,7 +178,7 @@ class provisionConfig_http_ssl_site extends provisionConfig_http_site {
dt("SSL Certificate directory for %key on %server", array(
'%key' => $this->ssl_key,
'%server' => $this->data['server']->remote_host,
)), 700);
)), 0700);
// Copy the certificates to the server's ssl.d directory.
provision_file()->copy(
......@@ -200,9 +201,9 @@ class provisionConfig_http_ssl_site extends provisionConfig_http_site {
$used = provisionService_http_ssl::certificate_in_use($this->data['ssl_key']);
if (!$used) {
// we can remove the certificate from the server ssl.d directory.
provision_file()->rmdir(dirname($this->data['ssl_cert']));
#provision_file()->rmdir(dirname($this->data['ssl_cert']));
// remove the file from the remote server too.
$this->data['server']->sync(dirname($this->data['ssl_cert']));
#$this->data['server']->sync(dirname($this->data['ssl_cert']));
}
}
......@@ -215,7 +216,7 @@ class provisionConfig_http_ssl_site extends provisionConfig_http_site {
}
function filename() {
$this->data['http_vhostd_path'] . '/' . $this->uri . '_ssl';
return $this->data['http_vhostd_path'] . '/' . $this->uri . '_ssl';
}
}
......@@ -20,6 +20,27 @@ function provision_file() {
}
class provisionFileSystem extends provisionChainedState {
/**
* Copy file from $source to $destination.
*
* @param $source
* The path that you want copy.
* @param $destination
* The destination path.
*/
function copy($source, $destination) {
$this->_clear_state();
$this->tokens = array('@source' => $source, '@destination' => $destination);
$this->last_status = FALSE;
$this->last_status = copy($source, $destination);
return $this;
}
/**
* Determine if $path can be written to.
*
......@@ -269,6 +290,8 @@ class provisionFileSystem extends provisionChainedState {
return $this;
}
/**
* Extract gzip-compressed tar archive.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment