Skip to content

Commit

Permalink
Use an ongoing certificate to avoid leaving unmatched key/cert pair
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveLTN committed Feb 13, 2021
1 parent 657f3d2 commit 74496ca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions fs_overlay/opt/certs_manager/certs_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ def ensure_signed(domains, exit_on_failure = false)
OpenSSL.create_csr(domain)
if ACME.sign(domain)
chain_certs(domain)
Nginx.reload || exit(1)
Nginx.reload || fail_and_shutdown
puts "Signed certificate for #{domain.name}"
else
puts("Failed to obtain certs for #{domain.name}")
exit(1) if exit_on_failure
fail_and_shutdown if exit_on_failure
end
else
puts "Signing skipped for #{domain.name}, it expires at #{OpenSSL.expires_in_days(domain.signed_cert_path)} days from now."
Expand Down
5 changes: 5 additions & 0 deletions fs_overlay/opt/certs_manager/lib/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ def ensure_dummy_certificate_for_default_server
)
end
end

def fail_and_shutdown
Nginx.stop
exit(1)
end
end
2 changes: 1 addition & 1 deletion fs_overlay/opt/certs_manager/lib/nginx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def self.start(daemon = true)

unless success
puts "Nginx failed to start, exiting ..."
exit(1)
Commands.fail_and_shutdown
end
end

Expand Down

0 comments on commit 74496ca

Please sign in to comment.