lib/manageiq/appliance_console/certificate.rb in manageiq-appliance_console-3.3.3 vs lib/manageiq/appliance_console/certificate.rb in manageiq-appliance_console-4.0.0
- old
+ new
@@ -1,6 +1,8 @@
require "awesome_spawn"
+require "linux_admin"
+require "fileutils"
module ManageIQ
module ApplianceConsole
class Certificate
STATUS_COMPLETE = :complete
@@ -37,12 +39,15 @@
@extensions ||= %w(server client)
@realm ||= hostname.split(".")[1..-1].join(".").upcase if hostname
end
def request
+ undo_tracking if complete?
+
if should_request_key?
principal.register
+ remove_key_pair
request_certificate
# NOTE: status probably changed
set_owner_of_key unless rejected?
end
@@ -101,10 +106,31 @@
def status
@status ||= key_status
end
+ def enable_certmonger
+ say("enabling certmonger to start on reboot")
+ LinuxAdmin::Service.new("certmonger").enable.start
+ end
+
private
+
+ def remove_key_pair
+ FileUtils.rm_f(cert_filename) if File.exist?(cert_filename)
+ FileUtils.rm_f(key_filename) if File.exist?(key_filename)
+ end
+
+ def undo_tracking
+ stop_tracking
+ FileUtils.rm_f(root_filename) if File.exist?(root_filename)
+ remove_key_pair
+ clear_status
+ end
+
+ def stop_tracking
+ AwesomeSpawn.run!("/usr/bin/getcert", :params => ["stop-tracking", "-f", cert_filename, "-k", key_filename])
+ end
def request_first
params = {
nil => "request",
"-c" => ca_name,