Module: PactBroker::Certificates::Service
Instance Method Summary
collapse
Methods included from Logging
included, log_error, log_with_tag
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
logger.warn("Error adding certificate object #{certificate} to store", e)
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
logger.warn("Error creating certificate object from certificate #{certificate.uuid} '#{certificate.description}'", e)
nil
end
end
end.flatten.compact
end
|