Adds SSL/TLS support
[integration/packaging/puppet-opendaylight.git] / lib / puppet / functions / convert_cert_to_string.rb
1 Puppet::Functions.create_function(:convert_cert_to_string) do
2   dispatch :convert_cert_to_string do
3     param 'String', :cert_file
4   end
5
6   def convert_cert_to_string(cert_file)
7     unless File.file?(cert_file)
8       raise puppet::ParseError, "Certificate file not found: #{cert_file}"
9     end
10     text=File.readlines(cert_file)
11     cert_string = ''
12     text.each do |line|
13       unless line.include? '-----'
14         cert_string += line.strip
15       end
16     end
17     return cert_string
18   end
19 end