[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

James Turnbull james at lovedthanlost.net
Wed Jul 14 10:29:53 UTC 2010


The following commit has been merged in the upstream branch:
commit 46f9d00714d8fa6c2dc88d1e4f19ed6786943220
Author: Brice Figureau <brice-puppet at daysofwonder.com>
Date:   Wed Jan 27 20:29:47 2010 +0100

    Fix #3117 - cert fingerprinting uses a method not available in ruby <= 1.8.6
    
    OpenSSL::Digest.hexdigest is not available on older ruby versions.
    This patch accesses directly to the digest instead (which hopefully
    support hexdigest).
    
    Signed-off-by: Brice Figureau <brice-puppet at daysofwonder.com>

diff --git a/lib/puppet/ssl/base.rb b/lib/puppet/ssl/base.rb
index 6c74b75..7452a51 100644
--- a/lib/puppet/ssl/base.rb
+++ b/lib/puppet/ssl/base.rb
@@ -68,7 +68,7 @@ class Puppet::SSL::Base
             raise ArgumentError, "#{md} is not a valid digest algorithm for fingerprinting certificate #{name}"
         end
 
-        OpenSSL::Digest.hexdigest(md, content.to_der).scan(/../).join(':').upcase
+        OpenSSL::Digest.const_get(md).hexdigest(content.to_der).scan(/../).join(':').upcase
     end
 
     private
diff --git a/spec/unit/ssl/base.rb b/spec/unit/ssl/base.rb
index dfab3c8..062ea33 100755
--- a/spec/unit/ssl/base.rb
+++ b/spec/unit/ssl/base.rb
@@ -16,11 +16,13 @@ describe Puppet::SSL::Certificate do
             @cert = stub 'cert', :to_der => "DER"
             @base.stubs(:content).returns(@cert)
             OpenSSL::Digest.stubs(:constants).returns ["MD5", "DIGEST"]
+            @digest = stub_everything
+            OpenSSL::Digest.stubs(:const_get).returns @digest
         end
 
         it "should digest the certificate DER value and return a ':' seperated nibblet string" do
             @cert.expects(:to_der).returns("DER")
-            OpenSSL::Digest.expects(:hexdigest).with("MD5", "DER").returns "digest"
+            @digest.expects(:hexdigest).with("DER").returns "digest"
 
             @base.fingerprint.should == "DI:GE:ST"
         end
@@ -32,7 +34,8 @@ describe Puppet::SSL::Certificate do
         end
 
         it "should use the given digest algorithm" do
-            OpenSSL::Digest.expects(:hexdigest).with("DIGEST", "DER").returns "digest"
+            OpenSSL::Digest.stubs(:const_get).with("DIGEST").returns @digest
+            @digest.expects(:hexdigest).with("DER").returns "digest"
 
             @base.fingerprint(:digest).should == "DI:GE:ST"
         end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list