class method
Gem::Security::Signer.new
new(key, cert_chain, passphrase = nil, options = {})
lib/rubygems/security/signer.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/rubygems/security/signer.rb, line 68
def initialize(key, cert_chain, passphrase = nil, options = {})
@cert_chain = cert_chain
@key = key
@passphrase = passphrase
@options = DEFAULT_OPTIONS.merge(options)
unless @key
default_key = File.join Gem.default_key_path
@key = default_key if File.exist? default_key
end
unless @cert_chain
default_cert = File.join Gem.default_cert_path
@cert_chain = [default_cert] if File.exist? default_cert
end
@digest_name = Gem::Security::DIGEST_NAME
@digest_algorithm = Gem::Security.create_digest(@digest_name)
if @key && !@key.is_a?(OpenSSL::PKey::PKey)
@key = OpenSSL::PKey.read(File.read(@key), @passphrase)
end
if @cert_chain
@cert_chain = @cert_chain.compact.map do |cert|
next cert if OpenSSL::X509::Certificate === cert
cert = File.read cert if File.exist? cert
OpenSSL::X509::Certificate.new cert
end
load_cert_chain
end
end
Creates a new signer with an RSA key or path to a key, and a certificate chain containing X509 certificates, encoding certificates or paths to certificates.