223: def write
224: files = {
225: @certfile => @cert,
226: @keyfile => @key,
227: }
228: files[@cacertfile] = @cacert if defined?(@cacert)
229:
230: files.each { |file,thing|
231: if thing
232: next if FileTest.exists?(file)
233:
234: text = nil
235:
236: if thing.is_a?(OpenSSL::PKey::RSA) and @password
237:
238: text = thing.export(
239:
240: OpenSSL::Cipher::DES.new(:EDE3, :CBC),
241:
242: @password
243: )
244: else
245: text = thing.to_pem
246: end
247:
248: File.open(file, "w", 0660) { |f| f.print text }
249: end
250: }
251:
252: SSLCertificates.mkhash(Puppet[:certdir], @cacert, @cacertfile) if defined?(@cacert)
253: end