Class: Puppet::SSL::StateMachine::NeedKey Private
- Defined in:
- lib/puppet/ssl/state_machine.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Load or generate a private key. If the key exists, try to load the client cert and transition to Done. If the cert is mismatched or otherwise fails valiation, raise an error. If the key doesn’t exist yet, generate one, and save it. If the cert doesn’t exist yet, transition to NeedSubmitCSR.
Instance Attribute Summary
Attributes inherited from SSLState
Instance Method Summary collapse
- #next_state ⇒ Object private
Methods inherited from SSLState
#initialize, #log_error, #to_error
Constructor Details
This class inherits a constructor from Puppet::SSL::StateMachine::SSLState
Instance Method Details
#next_state ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/puppet/ssl/state_machine.rb', line 249 def next_state Puppet.debug(_("Loading/generating private key")) password = @cert_provider.load_private_key_password key = @cert_provider.load_private_key(Puppet[:certname], password: password) if key cert = @cert_provider.load_client_cert(Puppet[:certname]) if cert next_ctx = @ssl_provider.create_context( cacerts: @ssl_context.cacerts, crls: @ssl_context.crls, private_key: key, client_cert: cert ) return Done.new(@machine, next_ctx) end else if Puppet[:key_type] == 'ec' Puppet.info _("Creating a new EC SSL key for %{name} using curve %{curve}") % { name: Puppet[:certname], curve: Puppet[:named_curve] } key = OpenSSL::PKey::EC.generate(Puppet[:named_curve]) else Puppet.info _("Creating a new RSA SSL key for %{name}") % { name: Puppet[:certname] } key = OpenSSL::PKey::RSA.new(Puppet[:keylength].to_i) end @cert_provider.save_private_key(Puppet[:certname], key, password: password) end NeedSubmitCSR.new(@machine, @ssl_context, key) end |