made signature algorithm configurable
[stack/cam.git] / cam / ca.py
index 0bf7fcf..f870389 100644 (file)
--- a/cam/ca.py
+++ b/cam/ca.py
@@ -28,7 +28,7 @@ class CA(object):
         self.basedir = basedir
         self.config = {'basedir': basedir, 'default_days': '365', 'ou': 'CA',
                        'days': '3650', 'country': 'XX', 'crl_url': '',
-                       'bits': '4096'}
+                       'signature_algorithm': 'sha1', 'bits': '2048'}
         self.config.update(config)
         self.files = _CAFiles(basedir, 
                               conf='conf/ca.conf',
@@ -113,6 +113,7 @@ class CA(object):
                 self.basedir, self.files.conf,
                 'ca', '-keyfile', self.files.private_key,
                 '-key', self._getpw(),
+                '-md', self.config['signature_algorithm'],
                 '-extensions', 'v3_ca', '-out', self.files.public_key,
                 '-days', self.config.get('days', self.config['default_days']),
                 '-selfsign', '-infiles', csr_file)
@@ -192,6 +193,7 @@ class CA(object):
                 self.basedir, conf_file,
                 'ca', '-days', conf['days'],
                 '-key', self._getpw(),
+                '-md', self.config['signature_algorithm'],
                 '-policy', 'policy_anything', '-out', cert.public_key_file,
                 '-extfile', ext_file, '-infiles', csr_file)
         finally: