-
Notifications
You must be signed in to change notification settings - Fork 1
/
letsencrypt.example.rake
32 lines (26 loc) · 1.01 KB
/
letsencrypt.example.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require "lets_encrypt_route53"
require "ssl_checker"
namespace :letsencrypt do
desc "Refresh the LetsEncrypt certificate if the current one expires in < 30 days"
task :validate => [:check, :refresh]
task :refresh do
le = LetsEncryptRoute53.new.tap do |config|
config.domain = "www.staging.scalar.sh"
config.endpoint = LetsEncryptRoute53::PRODUCTION
config.s3_bucket = "ops.scalar.sh"
config.s3_key = "#{config.domain}.letsencrypt.key.pem"
config.kms_key_id = "{key id}"
config.contact_email = "[email protected]"
config.hosted_zone_id = "Z34YXXXXXXXXXX"
config.load_balancer_name = "scalar-staging"
end
le.refresh_certificate!
end
task :check do
if (expires_in = SslChecker.new(host: "www.staging.scalar.sh").expires_in) > 30.days
days = expires_in.to_i / 1.day
puts "Current certificate is valid, and expires in #{days} days. Not updating."
exit 0
end
end
end