247: def write
248: files = {
249: @certfile => @cert,
250: @keyfile => @key,
251: }
252: if defined? @cacert
253: files[@cacertfile] = @cacert
254: end
255:
256: files.each { |file,thing|
257: if defined? thing and thing
258: if FileTest.exists?(file)
259: next
260: end
261:
262: text = nil
263:
264: if thing.is_a?(OpenSSL::PKey::RSA) and @password
265: text = thing.export(
266: OpenSSL::Cipher::DES.new(:EDE3, :CBC),
267: @password
268: )
269: else
270: text = thing.to_pem
271: end
272:
273: File.open(file, "w", 0660) { |f| f.print text }
274: end
275: }
276:
277: if defined? @cacert
278: SSLCertificates.mkhash(Puppet[:certdir], @cacert, @cacertfile)
279: end
280: end