Class: Puppet::SSL::StateMachine::NeedKey
- Defined in:
- lib/puppet/ssl/state_machine.rb
Overview
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
Methods inherited from SSLState
Constructor Details
This class inherits a constructor from Puppet::SSL::StateMachine::SSLState
Instance Method Details
#next_state ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/puppet/ssl/state_machine.rb', line 102 def next_state key = @cert_provider.load_private_key(Puppet[:certname]) 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 Puppet.info _("Creating a new SSL key for %{name}") % { name: Puppet[:certname] } key = OpenSSL::PKey::RSA.new(Puppet[:keylength].to_i) @cert_provider.save_private_key(Puppet[:certname], key) end NeedSubmitCSR.new(@machine, @ssl_context, key) end |