6
attr_writer :wait_for_cert, :one_time
9
def initialize(wait_time, is_one_time)
10
@wait_for_cert = wait_time
11
@one_time = is_one_time
15
# Did we just read a cert?
20
# Read, or retrieve if necessary, our certificate. Returns true if we retrieved
21
# a new cert, false if the cert already exists.
23
#NOTE: ACS this is checking that a file exists, maybe next time just do that?
25
# If we don't already have the certificate, then create a client to
26
# request one. Use the special ca stuff, don't use the normal server and port.
34
caclient = Puppet::Network::Client.ca.new()
38
if caclient.request_cert
39
break if read_new_cert
41
Puppet.notice "Did not receive certificate"
43
Puppet.notice "Set to run 'one time'; exiting with no certificate"
47
rescue StandardError => detail
48
Puppet.err "Could not request certificate: %s" % detail.to_s
55
Puppet.notice "waitforcert disabled; exiting with no certificate"
62
Puppet::Network::HttpPool.read_cert
66
if Puppet::Network::HttpPool.read_cert
67
# If we read it in, then we need to get rid of our existing http connection.
68
# The @new_cert flag will help us do that, in that it provides a way
69
# to notify that the cert status has changed.
71
Puppet.notice "Got signed certificate"
73
Puppet.err "Could not read certificates after retrieving them"