From d2634baa0ec8dc00170bd54bea25f526c8a7ed97 Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 19 Apr 2006 15:35:04 +0000 Subject: Fixing #118; the hash is now always 8 hex characters, 0-padded. Also changed the CA cert name to the FQDN of the host serving the CA, rather than "CAcert". git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1117 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/sslcertificates.rb | 4 +++- lib/puppet/sslcertificates/ca.rb | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/sslcertificates.rb b/lib/puppet/sslcertificates.rb index a56e64add..a003c6551 100755 --- a/lib/puppet/sslcertificates.rb +++ b/lib/puppet/sslcertificates.rb @@ -124,7 +124,8 @@ module Puppet::SSLCertificates end def self.mkhash(dir, cert, certfile) - hash = "%x" % cert.issuer.hash + # Make sure the hash is zero-padded to 8 chars + hash = "%08x" % cert.issuer.hash hashpath = nil 10.times { |i| path = File.join(dir, "%s.%s" % [hash, i]) @@ -149,6 +150,7 @@ module Puppet::SSLCertificates break } + return hashpath end require 'puppet/sslcertificates/certificate' diff --git a/lib/puppet/sslcertificates/ca.rb b/lib/puppet/sslcertificates/ca.rb index 04d950e21..aacf3352c 100644 --- a/lib/puppet/sslcertificates/ca.rb +++ b/lib/puppet/sslcertificates/ca.rb @@ -177,8 +177,13 @@ class Puppet::SSLCertificates::CA # Create the root certificate. def mkrootcert + # Make the root cert's name the FQDN of the host running the CA. + name = Facter["hostname"].value + if domain = Facter["domain"].value + name += "." + domain + end cert = Certificate.new( - :name => "CAcert", + :name => name, :cert => @config[:cacert], :encrypt => @config[:capass], :key => @config[:cakey], -- cgit