| Class | Gem::Security::Signer |
| In: |
lib/rubygems/security.rb
|
| Parent: | Object |
| cert_chain | [RW] | |
| key | [RW] |
# File lib/rubygems/security.rb, line 752
752: def initialize(key, cert_chain)
753: Gem.ensure_ssl_available
754: @algo = Gem::Security::OPT[:dgst_algo]
755: @key, @cert_chain = key, cert_chain
756:
757: # check key, if it's a file, and if it's key, leave it alone
758: if @key && !@key.kind_of?(OpenSSL::PKey::PKey)
759: @key = OpenSSL::PKey::RSA.new(File.read(@key))
760: end
761:
762: # check cert chain, if it's a file, load it, if it's cert data, convert
763: # it into a cert object, and if it's a cert object, leave it alone
764: if @cert_chain
765: @cert_chain = @cert_chain.map do |cert|
766: # check cert, if it's a file, load it, if it's cert data, convert it
767: # into a cert object, and if it's a cert object, leave it alone
768: if cert && !cert.kind_of?(OpenSSL::X509::Certificate)
769: cert = File.read(cert) if File::exist?(cert)
770: cert = OpenSSL::X509::Certificate.new(cert)
771: end
772: cert
773: end
774: end
775: end