aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/security/trust_dir.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-21 10:20:47 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-21 10:20:47 +0000
commit5335ce0e060c7a2a0b01c57f8f8a64254f2658e1 (patch)
treec63321cb7c7c5c15454a79d81123c7188be2c51e /lib/rubygems/security/trust_dir.rb
parent2f023c5dbaadede9ceac3eb9ac0e73f3050e5ada (diff)
downloadruby-5335ce0e060c7a2a0b01c57f8f8a64254f2658e1.tar.gz
Merge master branch from rubygems/rubygems upstream.
* Enable Style/MethodDefParentheses in Rubocop https://github.com/rubygems/rubygems/pull/2478 * Enable Style/MultilineIfThen in Rubocop https://github.com/rubygems/rubygems/pull/2479 * Fix required_ruby_version with prereleases and improve error message https://github.com/rubygems/rubygems/pull/2344 * Fix bundler rubygems binstub not properly looking for bundler https://github.com/rubygems/rubygems/pull/2426 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/security/trust_dir.rb')
-rw-r--r--lib/rubygems/security/trust_dir.rb15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/rubygems/security/trust_dir.rb b/lib/rubygems/security/trust_dir.rb
index 6d837affa1..98031ea22b 100644
--- a/lib/rubygems/security/trust_dir.rb
+++ b/lib/rubygems/security/trust_dir.rb
@@ -22,7 +22,7 @@ class Gem::Security::TrustDir
# Creates a new TrustDir using +dir+ where the directory and file
# permissions will be checked according to +permissions+
- def initialize dir, permissions = DEFAULT_PERMISSIONS
+ def initialize(dir, permissions = DEFAULT_PERMISSIONS)
@dir = dir
@permissions = permissions
@@ -32,7 +32,7 @@ class Gem::Security::TrustDir
##
# Returns the path to the trusted +certificate+
- def cert_path certificate
+ def cert_path(certificate)
name_path certificate.subject
end
@@ -59,7 +59,7 @@ class Gem::Security::TrustDir
# Returns the issuer certificate of the given +certificate+ if it exists in
# the trust directory.
- def issuer_of certificate
+ def issuer_of(certificate)
path = name_path certificate.issuer
return unless File.exist? path
@@ -70,7 +70,7 @@ class Gem::Security::TrustDir
##
# Returns the path to the trusted certificate with the given ASN.1 +name+
- def name_path name
+ def name_path(name)
digest = @digester.hexdigest name.to_s
File.join @dir, "cert-#{digest}.pem"
@@ -79,7 +79,7 @@ class Gem::Security::TrustDir
##
# Loads the given +certificate_file+
- def load_certificate certificate_file
+ def load_certificate(certificate_file)
pem = File.read certificate_file
OpenSSL::X509::Certificate.new pem
@@ -88,7 +88,7 @@ class Gem::Security::TrustDir
##
# Add a certificate to trusted certificate list.
- def trust_cert certificate
+ def trust_cert(certificate)
verify
destination = cert_path certificate
@@ -105,7 +105,7 @@ class Gem::Security::TrustDir
# permissions.
def verify
- if File.exist? @dir then
+ if File.exist? @dir
raise Gem::Security::Exception,
"trust directory #{@dir} is not a directory" unless
File.directory? @dir
@@ -117,4 +117,3 @@ class Gem::Security::TrustDir
end
end
-