Commit 190268ac authored by ale's avatar ale

add --password option for the CA password

parent 29c8be70
......@@ -12,7 +12,7 @@ class ConfigError(Exception):
pass
def read_config(filename):
def read_config(filename, password=None):
parser = configparser.ConfigParser()
if not parser.read(filename):
raise ConfigError('File not found: %s' % filename)
......@@ -21,7 +21,7 @@ def read_config(filename):
if parser.has_section('global'):
global_config = dict(parser.items('global'))
root_dir = global_config.get('root_dir', root_dir)
ca_obj = ca.CA(root_dir, dict(parser.items('ca')))
ca_obj = ca.CA(root_dir, dict(parser.items('ca')), password=password)
certs = []
for section in parser.sections():
if section in ('ca', 'global'):
......
......@@ -149,6 +149,9 @@ def main():
parser.add_option('-d', '--debug', dest='debug', help='Be verbose',
action='store_true')
parser.add_option('-c', '--config', dest='config', help='Config file')
parser.add_option('--password', dest='password',
help='CA password '
'(insecure, use only for testing)')
opts, args = parser.parse_args()
if len(args) > 0 and args[0] == 'help':
......@@ -164,7 +167,8 @@ def main():
level=logging.DEBUG if opts.debug else logging.INFO)
try:
global_config, ca, certs = config.read_config(opts.config)
global_config, ca, certs = config.read_config(
opts.config, password=opts.password)
try:
cmd, args = args[0], args[1:]
if cmd not in cmd_table:
......
......@@ -32,7 +32,7 @@ cn = test.com
cf_fd.write(test_cfg)
cf_fd.close()
self.mox.StubOutWithMock(config.ca, 'CA', use_mock_anything=True)
config.ca.CA('root', {'something': 'else'}).AndReturn('ca')
config.ca.CA('root', {'something': 'else'}, password=None).AndReturn('ca')
self.mox.StubOutWithMock(config.cert, 'Cert', use_mock_anything=True)
config.cert.Cert('ca', 'cert1', {'cn': 'test.com'}).AndReturn('cert1')
self.mox.ReplayAll()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment