Module: PactBroker::Certificates::Service
Instance Method Summary collapse
Methods included from Logging
Instance Method Details
#cert_store ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pact_broker/certificates/service.rb', line 13 def cert_store cert_store = OpenSSL::X509::Store.new cert_store.set_default_paths find_all_certificates.each do | certificate | begin logger.debug("Loading certificate #{certificate.subject} in to cert store") cert_store.add_cert(certificate) rescue StandardError => e log_error e, "Error adding certificate object #{certificate.to_s} to store" end end cert_store end |
#find_all_certificates ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pact_broker/certificates/service.rb', line 27 def find_all_certificates Certificate.collect do | certificate | cert_arr = certificate.content.split(/(-----END [^\-]+-----)/).each_slice(2).map(&:join).map(&:strip).select{|s| !s.empty?} cert_arr.collect do |c| begin OpenSSL::X509::Certificate.new(c) rescue StandardError => e log_error e, "Error creating certificate object from certificate #{certificate.uuid} '#{certificate.description}'" nil end end end.flatten.compact end |