Class: IO::Endpoint::TLS::TrustStore
- Inherits:
-
Object
- Object
- IO::Endpoint::TLS::TrustStore
- Defined in:
- lib/io/endpoint/tls/trust_store.rb
Overview
Represents transport-neutral trusted certificate sources.
Instance Attribute Summary collapse
-
#certificates ⇒ Object
readonly
Returns the value of attribute certificates.
- #The individual trusted certificates encoded as PEM.(individualtrustedcertificatesencodedasPEM.) ⇒ Object readonly
Class Method Summary collapse
-
.load(path, **options) ⇒ Object
Load a PEM-encoded certificate bundle from the given path.
-
.parse(certificate_bundle, system_certificates: false) ⇒ Object
Parse a PEM-encoded certificate bundle into a trust store.
Instance Method Summary collapse
-
#initialize(certificates: [], system_certificates: false) ⇒ TrustStore
constructor
Initialize a trust store from PEM-encoded trusted certificates.
-
#inspect ⇒ Object
Get a representation of the trust store without exposing certificate material.
-
#system_certificates? ⇒ Boolean
Whether system-provided trusted certificates should be included.
Constructor Details
#initialize(certificates: [], system_certificates: false) ⇒ TrustStore
Initialize a trust store from PEM-encoded trusted certificates.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/io/endpoint/tls/trust_store.rb', line 36 def initialize(certificates: [], system_certificates: false) unless certificates.is_a?(Array) && certificates.all?{|certificate| certificate.is_a?(String)} raise TypeError, "Certificates must be provided as an array of strings!" end unless certificates.any? || system_certificates raise ArgumentError, "At least one source of trusted certificates must be specified!" end @certificates = certificates @system_certificates = system_certificates end |
Instance Attribute Details
#certificates ⇒ Object (readonly)
Returns the value of attribute certificates.
50 51 52 |
# File 'lib/io/endpoint/tls/trust_store.rb', line 50 def certificates @certificates end |
#The individual trusted certificates encoded as PEM.(individualtrustedcertificatesencodedasPEM.) ⇒ Object (readonly)
50 |
# File 'lib/io/endpoint/tls/trust_store.rb', line 50 attr :certificates |
Class Method Details
.load(path, **options) ⇒ Object
Load a PEM-encoded certificate bundle from the given path.
17 18 19 |
# File 'lib/io/endpoint/tls/trust_store.rb', line 17 def self.load(path, **) return parse(File.read(path), **) end |
.parse(certificate_bundle, system_certificates: false) ⇒ Object
Parse a PEM-encoded certificate bundle into a trust store.
27 28 29 |
# File 'lib/io/endpoint/tls/trust_store.rb', line 27 def self.parse(certificate_bundle, system_certificates: false) return self.new(certificates: Certificates.parse(certificate_bundle), system_certificates: system_certificates) end |
Instance Method Details
#inspect ⇒ Object
Get a representation of the trust store without exposing certificate material.
60 61 62 63 64 65 66 67 |
# File 'lib/io/endpoint/tls/trust_store.rb', line 60 def inspect attributes = { certificates: @certificates.size, system_certificates: @system_certificates, } return "\#<#{self.class} #{attributes.inspect}>" end |
#system_certificates? ⇒ Boolean
Whether system-provided trusted certificates should be included.
54 55 56 |
# File 'lib/io/endpoint/tls/trust_store.rb', line 54 def system_certificates? @system_certificates end |