In Files

  • rubygems/security.rb

Parent

Methods

Class/Module Index [+]

Quicksearch

Gem::Security::Signer

Basic OpenSSL-based package signing class.

Attributes

cert_chain[RW]
key[RW]

Public Class Methods

new(key, cert_chain) click to toggle source
 
               # File rubygems/security.rb, line 752
def initialize(key, cert_chain)
  Gem.ensure_ssl_available
  @algo = Gem::Security::OPT[:dgst_algo]
  @key, @cert_chain = key, cert_chain

  # check key, if it's a file, and if it's key, leave it alone
  if @key && !@key.kind_of?(OpenSSL::PKey::PKey)
    @key = OpenSSL::PKey::RSA.new(File.read(@key))
  end

  # check cert chain, if it's a file, load it, if it's cert data, convert
  # it into a cert object, and if it's a cert object, leave it alone
  if @cert_chain
    @cert_chain = @cert_chain.map do |cert|
      # check cert, if it's a file, load it, if it's cert data, convert it
      # into a cert object, and if it's a cert object, leave it alone
      if cert && !cert.kind_of?(OpenSSL::X509::Certificate)
        cert = File.read(cert) if File::exist?(cert)
        cert = OpenSSL::X509::Certificate.new(cert)
      end
      cert
    end
  end
end
            

Public Instance Methods

sign(data) click to toggle source

Sign data with given digest algorithm

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

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus