@@ -93,19 +93,20 @@ def create_system_context(cacerts:, path: Puppet[:ssl_trust_store])
9393 # @param client_cert [OpenSSL::X509::Certificate] client's cert whose public
9494 # key matches the `private_key`
9595 # @param revocation [:chain, :leaf, false] revocation mode
96+ # @param include_system_store [true, false] Also trust system CA
9697 # @return [Puppet::SSL::SSLContext] A context to use to create connections
9798 # @raise [Puppet::SSL::CertVerifyError] There was an issue with
9899 # one of the certs or CRLs.
99100 # @raise [Puppet::SSL::SSLError] There was an issue with the
100101 # `private_key`.
101102 # @api private
102- def create_context ( cacerts :, crls :, private_key :, client_cert :, revocation : Puppet [ :certificate_revocation ] )
103+ def create_context ( cacerts :, crls :, private_key :, client_cert :, revocation : Puppet [ :certificate_revocation ] , include_system_store : false )
103104 raise ArgumentError , _ ( "CA certs are missing" ) unless cacerts
104105 raise ArgumentError , _ ( "CRLs are missing" ) unless crls
105106 raise ArgumentError , _ ( "Private key is missing" ) unless private_key
106107 raise ArgumentError , _ ( "Client cert is missing" ) unless client_cert
107108
108- store = create_x509_store ( cacerts , crls , revocation )
109+ store = create_x509_store ( cacerts , crls , revocation , include_system_store : include_system_store )
109110 client_chain = verify_cert_with_store ( store , client_cert )
110111
111112 if !private_key . is_a? ( OpenSSL ::PKey ::RSA ) && !private_key . is_a? ( OpenSSL ::PKey ::EC )
@@ -133,12 +134,13 @@ def create_context(cacerts:, crls:, private_key:, client_cert:, revocation: Pupp
133134 # @param password [String, nil] If the private key is encrypted, decrypt
134135 # it using the password. If the key is encrypted, but a password is
135136 # not specified, then the key cannot be loaded.
137+ # @param include_system_store [true, false] Also trust system CA
136138 # @return [Puppet::SSL::SSLContext] A context to use to create connections
137139 # @raise [Puppet::SSL::CertVerifyError] There was an issue with
138140 # one of the certs or CRLs.
139141 # @raise [Puppet::Error] There was an issue with one of the required components.
140142 # @api private
141- def load_context ( certname : Puppet [ :certname ] , revocation : Puppet [ :certificate_revocation ] , password : nil )
143+ def load_context ( certname : Puppet [ :certname ] , revocation : Puppet [ :certificate_revocation ] , password : nil , include_system_store : false )
142144 cert = Puppet ::X509 ::CertProvider . new
143145 cacerts = cert . load_cacerts ( required : true )
144146 crls = case revocation
@@ -150,7 +152,7 @@ def load_context(certname: Puppet[:certname], revocation: Puppet[:certificate_re
150152 private_key = cert . load_private_key ( certname , required : true , password : password )
151153 client_cert = cert . load_client_cert ( certname , required : true )
152154
153- create_context ( cacerts : cacerts , crls : crls , private_key : private_key , client_cert : client_cert , revocation : revocation )
155+ create_context ( cacerts : cacerts , crls : crls , private_key : private_key , client_cert : client_cert , revocation : revocation , include_system_store : include_system_store )
154156 rescue OpenSSL ::PKey ::PKeyError => e
155157 raise Puppet ::SSL ::SSLError . new ( _ ( "Failed to load private key for host '%{name}': %{message}" ) % { name : certname , message : e . message } , e )
156158 end
0 commit comments