Class: InformationCard::CertificateUtil
- Inherits:
-
Object
- Object
- InformationCard::CertificateUtil
- Defined in:
- lib/information_card/certificate_util.rb
Class Method Summary collapse
Class Method Details
.lookup_private_key(directory, subject) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/information_card/certificate_util.rb', line 6 def self.lookup_private_key(directory, subject) path = File.join(directory, '*.crt') Dir[path].each do |cert_file| cert = OpenSSL::X509::Certificate.new(File.read(cert_file)) return OpenSSL::PKey::RSA.new(File.read(cert_file.gsub(/.crt$/, '') + ".key")) if (cert.subject.to_s == subject) end raise "No private key found in #{path.gsub(/\*.crt/, '')} with subject #{subject}" end |