Site.php

  1. 7.x-3.x http/Provision/Config/Nginx/Site.php
  2. 7.x-3.x http/Provision/Config/Apache/Ssl/Site.php
  3. 7.x-3.x http/Provision/Config/Nginx/Ssl/Site.php
  4. 7.x-3.x http/Provision/Config/Http/Site.php
  5. 7.x-3.x http/Provision/Config/Apache/Site.php
  6. 7.x-3.x Provision/Context/site.php
  7. 7.x-3.x Provision/Config/Drushrc/Site.php
  8. 7.x-3.x http/Provision/Config/Http/Ssl/Site.php

Classes

Namesort descending Description
Provision_Config_Http_Ssl_Site Base class for SSL enabled virtual hosts.

File

http/Provision/Config/Http/Ssl/Site.php
View source
  1. <?php
  2. /**
  3. * Base class for SSL enabled virtual hosts.
  4. *
  5. * This class primarily abstracts the process of making sure the relevant keys
  6. * are synched to the server when the config files that use them get created.
  7. */
  8. class Provision_Config_Http_Ssl_Site extends Provision_Config_Http_Site {
  9. public $template = 'vhost_ssl.tpl.php';
  10. public $disabled_template = 'vhost_ssl_disabled.tpl.php';
  11. public $description = 'encrypted virtual host configuration';
  12. function write() {
  13. parent::write();
  14. if ($this->ssl_enabled && $this->ssl_key) {
  15. $path = dirname($this->data['ssl_cert']);
  16. // Make sure the ssl.d directory in the server ssl.d exists.
  17. provision_file()->create_dir($path,
  18. dt("SSL Certificate directory for %key on %server", array(
  19. '%key' => $this->ssl_key,
  20. '%server' => $this->data['server']->remote_host,
  21. )), 0700);
  22. // Touch a file in the server's copy of this key, so that it knows the key is in use.
  23. // XXX: test. data structure may not be sound. try d($this->uri)
  24. // if $this fails
  25. Provision_Service_http_ssl::assign_certificate_site($this->ssl_key, $this);
  26. // Copy the certificates to the server's ssl.d directory.
  27. provision_file()->copy(
  28. $this->data['ssl_cert_source'],
  29. $this->data['ssl_cert'])
  30. || drush_set_error('SSL_CERT_COPY_FAIL', dt('failed to copy SSL certificate in place'));
  31. provision_file()->copy(
  32. $this->data['ssl_cert_key_source'],
  33. $this->data['ssl_cert_key'])
  34. || drush_set_error('SSL_KEY_COPY_FAIL', dt('failed to copy SSL key in place'));
  35. // Copy the chain certificate, if it is set.
  36. if (!empty($this->data['ssl_chain_cert_source'])) {
  37. provision_file()->copy(
  38. $this->data['ssl_chain_cert_source'],
  39. $this->data['ssl_chain_cert'])
  40. || drush_set_error('SSL_CHAIN_COPY_FAIL', dt('failed to copy SSL certficate chain in place'));
  41. }
  42. // Sync the key directory to the remote server.
  43. $this->data['server']->sync($path, array(
  44. 'exclude' => "{$path}/*.receipt", // Don't need to synch the receipts
  45. ));
  46. }
  47. }
  48. /**
  49. * Remove a stale certificate file from the server.
  50. */
  51. function unlink() {
  52. parent::unlink();
  53. if ($this->ssl_enabled) {
  54. // XXX: to be tested, not sure the data structure is sound
  55. Provision_Service_http_ssl::free_certificate_site($this->ssl_key, $this);
  56. }
  57. }
  58. /**
  59. * Small utility function to stop code duplication.
  60. *
  61. * @deprecated unused
  62. * @see Provision_Service_http_ssl::free_certificate_site()
  63. */
  64. private function clear_certs($ssl_key) {
  65. return FALSE;
  66. }
  67. }