X-Git-Url: https://pwan.org/git/?p=certmaster.git;a=blobdiff_plain;f=certmaster%2Fcertmaster.py;h=b0a216bbe52f961e1b394281b24b0fdf8aa178de;hp=9548b8b77d0071d6e3dccbf2a5e382fc026d74c6;hb=5bdd42c1534a196d6be9104543e4a9a9b0442324;hpb=c6eb51dbc3be8ef1b97ad66ac5f218d5d48c9ec0 diff --git a/certmaster/certmaster.py b/certmaster/certmaster.py index 9548b8b..b0a216b 100644 --- a/certmaster/certmaster.py +++ b/certmaster/certmaster.py @@ -22,7 +22,19 @@ import traceback import os import os.path from OpenSSL import crypto -import sha + +try: + import hashlib +except ImportError: + # Python-2.4.z ... gah! (or even 2.3!) + import sha + class hashlib: + @staticmethod + def new(algo): + if algo == 'sha1': + return sha.new() + raise ValueError, "Bad checksum type" + import glob import socket import exceptions @@ -123,10 +135,10 @@ class CertMaster(object): if os.path.exists(csrfile): oldfo = open(csrfile) oldcsrbuf = oldfo.read() - oldsha = sha.new() + oldsha = hashlib.new('sha1') oldsha.update(oldcsrbuf) olddig = oldsha.hexdigest() - newsha = sha.new() + newsha = hashlib.new('sha1') newsha.update(csrbuf) newdig = newsha.hexdigest() if not newdig == olddig: