@@ -93,19 +93,20 @@ def create_system_context(cacerts:, path: Puppet[:ssl_trust_store])
93
93
# @param client_cert [OpenSSL::X509::Certificate] client's cert whose public
94
94
# key matches the `private_key`
95
95
# @param revocation [:chain, :leaf, false] revocation mode
96
+ # @param include_system_store [true, false] Also trust system CA
96
97
# @return [Puppet::SSL::SSLContext] A context to use to create connections
97
98
# @raise [Puppet::SSL::CertVerifyError] There was an issue with
98
99
# one of the certs or CRLs.
99
100
# @raise [Puppet::SSL::SSLError] There was an issue with the
100
101
# `private_key`.
101
102
# @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 )
103
104
raise ArgumentError , _ ( "CA certs are missing" ) unless cacerts
104
105
raise ArgumentError , _ ( "CRLs are missing" ) unless crls
105
106
raise ArgumentError , _ ( "Private key is missing" ) unless private_key
106
107
raise ArgumentError , _ ( "Client cert is missing" ) unless client_cert
107
108
108
- store = create_x509_store ( cacerts , crls , revocation )
109
+ store = create_x509_store ( cacerts , crls , revocation , include_system_store : include_system_store )
109
110
client_chain = verify_cert_with_store ( store , client_cert )
110
111
111
112
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
133
134
# @param password [String, nil] If the private key is encrypted, decrypt
134
135
# it using the password. If the key is encrypted, but a password is
135
136
# not specified, then the key cannot be loaded.
137
+ # @param include_system_store [true, false] Also trust system CA
136
138
# @return [Puppet::SSL::SSLContext] A context to use to create connections
137
139
# @raise [Puppet::SSL::CertVerifyError] There was an issue with
138
140
# one of the certs or CRLs.
139
141
# @raise [Puppet::Error] There was an issue with one of the required components.
140
142
# @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 )
142
144
cert = Puppet ::X509 ::CertProvider . new
143
145
cacerts = cert . load_cacerts ( required : true )
144
146
crls = case revocation
@@ -150,7 +152,7 @@ def load_context(certname: Puppet[:certname], revocation: Puppet[:certificate_re
150
152
private_key = cert . load_private_key ( certname , required : true , password : password )
151
153
client_cert = cert . load_client_cert ( certname , required : true )
152
154
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 )
154
156
rescue OpenSSL ::PKey ::PKeyError => e
155
157
raise Puppet ::SSL ::SSLError . new ( _ ( "Failed to load private key for host '%{name}': %{message}" ) % { name : certname , message : e . message } , e )
156
158
end
0 commit comments