From 8cd61a06f21edfde8e83e65b70f20e6743a4f5ef Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Wed, 3 Sep 2014 11:52:14 -0700 Subject: [PATCH] ssl sites bundler --- .gitignore | 1 + Rakefile | 24 ++++++++++++++++++++++++ views/custom_domain.erb | 4 ++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0a7a9c09..8b95d547 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ public/site_thumbnails_test files/map.txt .sass-cache .sass-cache/* +files/sslsites.zip diff --git a/Rakefile b/Rakefile index 1fcc1216..75942c3b 100644 --- a/Rakefile +++ b/Rakefile @@ -88,3 +88,27 @@ desc 'Compile domain map for nginx' task :compile_domain_map => [:environment] do File.open('./files/map.txt', 'w'){|f| Site.exclude(domain: nil).exclude(domain: '').select(:username,:domain).all.collect {|s| f.write "#{s.domain} #{s.username};\n" }} end + +desc 'Produce SSL config package for proxy' +task :buildssl => [:environment] do + sites = Site.select(:id, :username, :domain, :ssl_key, :ssl_cert, :ssl_cert_intermediate). + exclude(domain: nil). + exclude(ssl_key: nil). + exclude(ssl_cert: nil). + exclude(ssl_cert_intermediate: nil). + all + + payload = [] + + Zip::Archive.open('./files/sslsites.zip', Zip::CREATE) do |ar| + ar.add_dir 'ssl' + + sites.each do |site| + ar.add_buffer "ssl/#{site.username}.key", site.ssl_key + ar.add_buffer "ssl/#{site.username}.crt", "#{site.ssl_cert_intermediate}\n\n#{site.ssl_cert}" + payload << {username: site.username, domain: site.domain} + end + + ar.add_buffer 'sslsites.json', payload.to_json + end +end \ No newline at end of file diff --git a/views/custom_domain.erb b/views/custom_domain.erb index 4abaa438..720b753a 100644 --- a/views/custom_domain.erb +++ b/views/custom_domain.erb @@ -46,7 +46,7 @@

Add SSL Certificate

- This allows you to add an SSL private key and certificate for your domain, enabling encryption for your site (https). It can take up to 5-30 minutes for the changes to go live, so please be patient. + This allows you to add an SSL key and certificate for your domain, enabling encryption for your site (https). It can take up to 5-30 minutes for the changes to go live, so please be patient.

<% if current_site.domain.nil? || current_site.domain.empty? %> @@ -63,7 +63,7 @@

- Private key (yourdomain.com.key): + SSL Key (yourdomain.com.key):