The TrustDir manages the trusted certificates for gem signature verification.
- C
- E
- I
- L
- N
- T
- V
Constants
| DEFAULT_PERMISSIONS | = | { trust_dir: 0o700, trusted_cert: 0o600, }.freeze |
Default permissions for the trust directory and its contents |
||
Attributes
| [R] | dir | The directory where trusted certificates will be stored. |
Class Public methods
new(dir, permissions = DEFAULT_PERMISSIONS) Link
Creates a new TrustDir using dir where the directory and file permissions will be checked according to permissions
Instance Public methods
cert_path(certificate) Link
Returns the path to the trusted certificate
each_certificate() Link
Enumerates trusted certificates.
# File ruby/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| certificate = load_certificate certificate_file yield certificate, certificate_file rescue OpenSSL::X509::CertificateError next # HACK: warn end end
issuer_of(certificate) Link
Returns the issuer certificate of the given certificate if it exists in the trust directory.
load_certificate(certificate_file) Link
Loads the given certificate_file
name_path(name) Link
Returns the path to the trusted certificate with the given ASN.1 name
trust_cert(certificate) Link
Add a certificate to trusted certificate list.
verify() Link
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 ruby/lib/rubygems/security/trust_dir.rb, line 105 def verify require "fileutils" if File.exist? @dir raise Gem::Security::Exception, "trust directory #{@dir} is not a directory" unless File.directory? @dir FileUtils.chmod 0o700, @dir else FileUtils.mkdir_p @dir, mode: @permissions[:trust_dir] end end