Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/puppet/ssl/state_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def next_state
Wait.new(@machine)
else
to_error(_("Failed to retrieve certificate for %{certname}: %{message}") %
{ certname: Puppet[:certname], message: e.response.message }, e)
{ certname: Puppet[:certname], message: e.message }, e)
end
end
end
Expand Down Expand Up @@ -391,7 +391,7 @@ def next_state
end
Done.new(@machine, @ssl_context)
rescue => e
Puppet.warning(_("Unable to automatically renew certificate: %{message}") % { message: e })
Puppet.warning(_("Unable to automatically renew certificate: %{message}") % { message: e.message })
Done.new(@machine, @ssl_context)
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/unit/ssl/state_machine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,14 @@ def write_csr_attributes(data)
expect(state.next_state).to be_an_instance_of(Puppet::SSL::StateMachine::Wait)
end

it 'transitions to Error if the server returns 500' do
stub_request(:get, %r{puppet-ca/v1/certificate/#{Puppet[:certname]}}).to_return(status: 500)

st = state.next_state
expect(st).to be_an_instance_of(Puppet::SSL::StateMachine::Error)
expect(st.message).to match(/Failed to retrieve certificate/)
end

it "verifies the server's certificate when getting the client cert" do
stub_request(:get, %r{puppet-ca/v1/certificate/#{Puppet[:certname]}}).to_return(status: 200, body: client_cert.to_pem)
allow(cert_provider).to receive(:save_client_cert)
Expand Down