Class Gem::Security::Signer
In: lib/rubygems/security.rb
Parent: Object

Basic OpenSSL-based package signing class.

Methods

new   sign  

Attributes

cert_chain  [RW] 
key  [RW] 

Public Class methods

[Source]

     # 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

Public Instance methods

Sign data with given digest algorithm

[Source]

     # File lib/rubygems/security.rb, line 780
780:     def sign(data)
781:       @key.sign(@algo.new, data)
782:     end

[Validate]