X-Git-Url: https://pwan.org/git/?p=certmaster.git;a=blobdiff_plain;f=scripts%2Fcertmaster-sync;fp=scripts%2Fcertmaster-sync;h=8e6db440ed03558485b231e367e98f3164422a8f;hp=ca7710ed66277dafa12d7cb9631b46e482e51917;hb=67e8a55e10f81105cb76e7c1ff9d0615cf97dff5;hpb=88c38a52cf4da57c8b0a910762ca69cc8dbec61f diff --git a/scripts/certmaster-sync b/scripts/certmaster-sync index ca7710e..8e6db44 100644 --- a/scripts/certmaster-sync +++ b/scripts/certmaster-sync @@ -7,6 +7,7 @@ import os import sys +import warning try: import hashlib except ImportError: @@ -16,6 +17,7 @@ except ImportError: @staticmethod def new(algo): if algo == 'sha1': + warnings.warn('sha1 is deprecated',DeprecationWarning) return sha.new() raise ValueError, "Bad checksum type" @@ -76,7 +78,7 @@ def remote_peers(hosts): def local_certs(): """ - Returns (hostname, sha1) hash of local certs + Returns (hostname, hashval) hash of local certs """ globby = '*.%s' % cm.cfg.cert_extension globby = os.path.join(cm.cfg.certroot, globby) @@ -85,12 +87,12 @@ def local_certs(): for f in files: hostname = os.path.basename(f).replace('.' + cm.cfg.cert_extension, '') dirname = os.path.dirname(f) - digest = checksum(f) + digest = checksum(f,cm.cfg.hashfunc) results.append([hostname, digest, dirname]) return results -def checksum(f): - thissum = hashlib.new('sha1') +def checksum(f,hashfunc): + thissum = hashlib.new(hashfunc) if os.path.exists(f): fo = open(f, 'r') data = fo.read()