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 790
790:     def initialize(key, cert_chain)
791:       Gem.ensure_ssl_available
792:       @algo = Gem::Security::OPT[:dgst_algo]
793:       @key, @cert_chain = key, cert_chain
794: 
795:       # check key, if it's a file, and if it's key, leave it alone
796:       if @key && !@key.kind_of?(OpenSSL::PKey::PKey)
797:         @key = OpenSSL::PKey::RSA.new(File.read(@key))
798:       end
799: 
800:       # check cert chain, if it's a file, load it, if it's cert data, convert
801:       # it into a cert object, and if it's a cert object, leave it alone
802:       if @cert_chain
803:         @cert_chain = @cert_chain.map do |cert|
804:           # check cert, if it's a file, load it, if it's cert data, convert it
805:           # into a cert object, and if it's a cert object, leave it alone
806:           if cert && !cert.kind_of?(OpenSSL::X509::Certificate)
807:             cert = File.read(cert) if File::exist?(cert)
808:             cert = OpenSSL::X509::Certificate.new(cert)
809:           end
810:           cert
811:         end
812:       end
813:     end

Public Instance methods

Sign data with given digest algorithm

[Source]

     # File lib/rubygems/security.rb, line 818
818:     def sign(data)
819:       @key.sign(@algo.new, data)
820:     end

[Validate]