Sha256: 29e90e0fb9e5d45621fa5515488cc1c73a019beebb009b3df92488dcbeb23c6a
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
module Digicert module CLI class CertificateDownloader def initialize(certificate_id:, path:, **options) @path = path @options = options @certificate_id = certificate_id @filename = options.fetch(:filename, certificate_id) end def download if certificate_contents write_certificate_contents(certificate_contents) end end def self.download(attributes) new(**attributes).download end private attr_reader :certificate_id, :path, :filename, :options def certificate_contents @certificate_contents ||= Digicert::CertificateDownloader.fetch_content(certificate_id) end def write_certificate_contents(contents) say("Downloaded certificate to:") write_to_path("root", contents[:root_certificate]) write_to_path("certificate", contents[:certificate]) write_to_path("intermediate", contents[:intermediate_certificate]) end def write_to_path(key, content) certificate_name = [filename, key, "crt"].join(".") certificate_path = [path, certificate_name].join("/") say(certificate_path) File.open(certificate_path, "w") { |file| file.write(content) } end def say(message) Digicert::CLI::Util.say(message) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
digicert-cli-1.0.0 | lib/digicert/cli/certificate_downloader.rb |