diff options
| author | Michael V. O'Brien <michael@reductivelabs.com> | 2007-10-19 13:47:17 -0500 |
|---|---|---|
| committer | Michael V. O'Brien <michael@reductivelabs.com> | 2007-10-19 13:47:17 -0500 |
| commit | 264331b3287067251c202c96ceb3a6d1f5039976 (patch) | |
| tree | ed9eb9dd948c8fd0074c6d71927fa70f37c88afa /lib/puppet | |
| parent | ec396729d76b26d0d08c0bd633f28fa3c68c414c (diff) | |
| download | puppet-264331b3287067251c202c96ceb3a6d1f5039976.tar.gz puppet-264331b3287067251c202c96ceb3a6d1f5039976.tar.xz puppet-264331b3287067251c202c96ceb3a6d1f5039976.zip | |
Partial work done for ssl certificates.
Diffstat (limited to 'lib/puppet')
| -rw-r--r-- | lib/puppet/indirector/ssl_rsa.rb | 5 | ||||
| -rw-r--r-- | lib/puppet/indirector/ssl_rsa/file.rb | 33 | ||||
| -rw-r--r-- | lib/puppet/sslcertificates/monkey_patch.rb | 6 |
3 files changed, 44 insertions, 0 deletions
diff --git a/lib/puppet/indirector/ssl_rsa.rb b/lib/puppet/indirector/ssl_rsa.rb new file mode 100644 index 000000000..162d8200a --- /dev/null +++ b/lib/puppet/indirector/ssl_rsa.rb @@ -0,0 +1,5 @@ +# This is a stub class + +class Puppet::Indirector::SslRsa #:nodoc: +end + diff --git a/lib/puppet/indirector/ssl_rsa/file.rb b/lib/puppet/indirector/ssl_rsa/file.rb new file mode 100644 index 000000000..435aa8f86 --- /dev/null +++ b/lib/puppet/indirector/ssl_rsa/file.rb @@ -0,0 +1,33 @@ +require 'puppet/indirector/file' +require 'puppet/indirector/ssl_rsa' + +class Puppet::Indirector::SslRsa::File < Puppet::Indirector::File + desc "Store SSL keys on disk." + + def initialize + Puppet.settings.use(:ssl) + end + + def path(name) + if name == :ca + File.join Puppet.settings[:cadir], "ca_key.pem" + else + File.join Puppet.settings[:publickeydir], name.to_s + ".pem" + end + end + + def save(key) + File.open(path(key.name), "w") { |f| f.print key.to_pem } + end + + def find(name) + return nil unless FileTest.exists?(path(name)) + OpenSSL::PKey::RSA.new(File.read(path(name))) + end + + def destroy(name) + return nil unless FileTest.exists?(path(name)) + File.unlink(path(name)) and true + end + +end diff --git a/lib/puppet/sslcertificates/monkey_patch.rb b/lib/puppet/sslcertificates/monkey_patch.rb new file mode 100644 index 000000000..663b944c1 --- /dev/null +++ b/lib/puppet/sslcertificates/monkey_patch.rb @@ -0,0 +1,6 @@ +# This is the file that we use to add indirection to all the SSL Certificate classes. + +require 'puppet/indirector' + +OpenSSL::PKey::RSA.extend Puppet::Indirector +OpenSSL::PKey::RSA.indirects :ssl_rsa, :terminus_class => :file |
