summaryrefslogtreecommitdiff
path: root/lib/rubygems/security.rb
diff options
context:
space:
mode:
-rw-r--r--lib/rubygems/security.rb55
1 files changed, 23 insertions, 32 deletions
@@ -12,6 +12,20 @@ begin
rescue LoadError => e
raise unless (e.respond_to?(:path) && e.path == 'openssl') ||
e.message =~ / -- openssl$/
end
##
@@ -338,26 +352,17 @@ module Gem::Security
##
# Digest algorithm used to sign gems
- DIGEST_ALGORITHM =
- if defined?(OpenSSL::Digest) then
- OpenSSL::Digest::SHA1
- end
##
# Used internally to select the signing digest from all computed digests
- DIGEST_NAME = # :nodoc:
- if DIGEST_ALGORITHM then
- DIGEST_ALGORITHM.new.name
- end
##
# Algorithm for creating the key pair used to sign gems
- KEY_ALGORITHM =
- if defined?(OpenSSL::PKey) then
- OpenSSL::PKey::RSA
- end
##
# Length of keys created by KEY_ALGORITHM
@@ -365,12 +370,6 @@ module Gem::Security
KEY_LENGTH = 2048
##
- # Cipher used to encrypt the key pair used to sign gems.
- # Must be in the list returned by OpenSSL::Cipher.ciphers
-
- KEY_CIPHER = OpenSSL::Cipher.new('AES-256-CBC') if defined?(OpenSSL::Cipher)
-
- ##
# One year in seconds
ONE_YEAR = 86400 * 365
@@ -564,18 +563,13 @@ module Gem::Security
##
# Writes +pemmable+, which must respond to +to_pem+ to +path+ with the given
- # +permissions+. If passed +cipher+ and +passphrase+ those arguments will be
- # passed to +to_pem+.
- def self.write pemmable, path, permissions = 0600, passphrase = nil, cipher = KEY_CIPHER
path = File.expand_path path
open path, 'wb', permissions do |io|
- if passphrase and cipher
- io.write pemmable.to_pem cipher, passphrase
- else
- io.write pemmable.to_pem
- end
end
path
@@ -585,11 +579,8 @@ module Gem::Security
end
-if defined?(OpenSSL::SSL) then
- require 'rubygems/security/policy'
- require 'rubygems/security/policies'
- require 'rubygems/security/trust_dir'
-end
-
require 'rubygems/security/signer'