diff options
author | James Turnbull <james@lovedthanlost.net> | 2011-10-04 13:00:16 -0700 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2011-10-04 13:00:16 -0700 |
commit | 14852e0259e1e43371dbcb2675e00c6d6e614f05 (patch) | |
tree | 1fec7a39efcb6dc398565d3f2472bb7e44e7f1f2 /lib/puppet/parser/functions/get_pubkey.rb | |
parent | a95dccd464b55945feb8bcf7483f777c25164115 (diff) | |
parent | 9b912d028fe1a2622ec61a56b1f0774ef3c9f43b (diff) | |
download | puppet-stdlib-14852e0259e1e43371dbcb2675e00c6d6e614f05.tar.gz puppet-stdlib-14852e0259e1e43371dbcb2675e00c6d6e614f05.tar.bz2 |
Merge pull request #13 from kbarber/issue/master/8925-user_ssl_certs
(#8925) Added new function called 'get_certificate' for retrieving
Diffstat (limited to 'lib/puppet/parser/functions/get_pubkey.rb')
-rw-r--r-- | lib/puppet/parser/functions/get_pubkey.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/get_pubkey.rb b/lib/puppet/parser/functions/get_pubkey.rb new file mode 100644 index 0000000..744b9df --- /dev/null +++ b/lib/puppet/parser/functions/get_pubkey.rb @@ -0,0 +1,25 @@ +module Puppet::Parser::Functions + newfunction(:get_pubkey, :type => :rvalue, :doc => <<-EOS +Gets a public key given a CN. This function accepts all the same +parameters as get_certificate(), but instead returns the public +key portion of the certificate. + +See get_certificate() for a more complete list of options available. +EOS + ) do |arguments| + + # Wrap the get_certificate method + method = Puppet::Parser::Functions.function(:get_certificate) + cert_text = send(method, arguments) + + require 'openssl' + + if cert_text == :undef then + return :undef + else + cert = OpenSSL::X509::Certificate.new(cert_text) + pubkey = cert.public_key + return pubkey.to_s + end + end +end |