frozen_string_literal: false
The TrustDir manages the trusted certificates for gem signature verification.
- C
- E
- I
- L
- N
- T
- V
| DEFAULT_PERMISSIONS | = | { :trust_dir => 0700, :trusted_cert => 0600, } |
Default permissions for the trust directory and its contents |
||
| [R] | dir | The directory where trusted certificates will be stored. |
Creates a new TrustDir using dir
where the directory and file permissions will be checked according to
permissions
Returns the path to the trusted certificate
Enumerates trusted certificates.
# File lib/rubygems/security/trust_dir.rb, line 42 def each_certificate return enum_for __method__ unless block_given? glob = File.join @dir, '*.pem' Dir[glob].each do |certificate_file| begin certificate = load_certificate certificate_file yield certificate, certificate_file rescue OpenSSL::X509::CertificateError next # HACK warn end end end
Returns the issuer certificate of the given certificate if it
exists in the trust directory.
Loads the given certificate_file
Returns the path to the trusted certificate with the given ASN.1
name
Add a certificate to trusted certificate list.
Make sure the trust directory exists. If it does exist, make sure it's actually a directory. If not, then create it with the appropriate permissions.
# File lib/rubygems/security/trust_dir.rb, line 106 def verify if File.exist? @dir then raise Gem::Security::Exception, "trust directory #{@dir} is not a directory" unless File.directory? @dir FileUtils.chmod 0700, @dir else FileUtils.mkdir_p @dir, :mode => @permissions[:trust_dir] end end