summaryrefslogtreecommitdiffstats
path: root/ipaserver/install/certs.py
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2009-07-23 16:58:21 -0400
committerJason Gerard DeRose <jderose@redhat.com>2009-07-23 20:03:01 -0600
commit5767c6b37d68e645bce5666ec803570e12e22560 (patch)
tree2c7b63007a7e425b45d738810399bed3de5d3903 /ipaserver/install/certs.py
parentb382755feebc4f9a0cf0f985d84c81d57307e542 (diff)
downloadfreeipa-5767c6b37d68e645bce5666ec803570e12e22560.tar.gz
freeipa-5767c6b37d68e645bce5666ec803570e12e22560.tar.xz
freeipa-5767c6b37d68e645bce5666ec803570e12e22560.zip
Fix deprecation warning for the sha library on Python 2.6
sha has been replaced by hashlib. We need to support Python 2.4 - 2.6 so this will use hashlib if available but fall back onto sha if not. Fortunately they use the same API for the function we need. 509042 Signed-off-by: Jason Gerard DeRose <jderose@redhat.com>
Diffstat (limited to 'ipaserver/install/certs.py')
-rw-r--r--ipaserver/install/certs.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/ipaserver/install/certs.py b/ipaserver/install/certs.py
index c1b7a8089..ad851489b 100644
--- a/ipaserver/install/certs.py
+++ b/ipaserver/install/certs.py
@@ -18,7 +18,6 @@
#
import os, stat, subprocess, re
-import sha
import errno
import tempfile
import shutil
@@ -34,6 +33,13 @@ from ipapython import ipautil
from nss.error import NSPRError
import nss.nss as nss
+# The sha module is deprecated in Python 2.6, replaced by hashlib. Try
+# that first and fall back to sha.sha if it isn't available.
+try:
+ from hashlib import sha256 as sha
+except ImportError:
+ from sha import sha
+
CA_SERIALNO="/var/lib/ipa/ca_serialno"
def ipa_self_signed():
@@ -194,7 +200,7 @@ class CertDB(object):
os.chmod(fname, perms)
def gen_password(self):
- return sha.sha(ipautil.ipa_generate_password()).hexdigest()
+ return sha(ipautil.ipa_generate_password()).hexdigest()
def run_certutil(self, args, stdin=None):
new_args = ["/usr/bin/certutil", "-d", self.secdir]