Skip to content

Commit a67fb1a

Browse files
committed
[_526] can now opt out of strong primes to speed up SSL & PAM tests
1 parent ed2e73c commit a67fb1a

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

irods/test/setupssl.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,28 @@ def create_server_cert(process_output = sys.stdout, irods_key_path = 'irods.key'
2525
p.wait()
2626
return p.returncode
2727

28-
def create_ssl_dir(irods_key_path = 'irods.key'):
28+
29+
def create_ssl_dir(irods_key_path = 'irods.key', ssl_dir = '', use_strong_primes_for_dh_generation = True):
30+
ssl_dir = ssl_dir or IRODS_SSL_DIR
2931
save_cwd = os.getcwd()
3032
silent_run = { 'shell': True, 'stderr' : PIPE, 'stdout' : PIPE }
3133
try:
32-
if not (os.path.exists(IRODS_SSL_DIR)):
33-
os.mkdir(IRODS_SSL_DIR)
34-
os.chdir(IRODS_SSL_DIR)
34+
if not (os.path.exists(ssl_dir)):
35+
os.mkdir(ssl_dir)
36+
os.chdir(ssl_dir)
3537
if not keep_old:
3638
Popen("openssl genrsa -out '{irods_key_path}' 2048 && chmod 600 '{irods_key_path}'".format(**locals()),
3739
**silent_run).communicate()
3840
with open("/dev/null","wb") as dev_null:
3941
if 0 == create_server_cert(process_output = dev_null, irods_key_path = irods_key_path):
4042
if not keep_old:
41-
Popen('openssl dhparam -2 -out dhparams.pem',**silent_run).communicate()
43+
# https://www.openssl.org/docs/man1.0.2/man1/dhparam.html#:~:text=DH%20parameter%20generation%20with%20the,that%20may%20be%20possible%20otherwise.
44+
if use_strong_primes_for_dh_generation:
45+
dhparam_generation_command = 'openssl dhparam -2 -out dhparams.pem'
46+
else:
47+
dhparam_generation_command = 'openssl dhparam -dsaparam -out dhparams.pem 4096'
48+
print('cmd=',dhparam_generation_command )
49+
Popen(dhparam_generation_command,**silent_run).communicate()
4250
return os.listdir(".")
4351
finally:
4452
os.chdir(save_cwd)
@@ -57,14 +65,17 @@ def test(options, args=()):
5765
if affirm[:1].lower() == 'y':
5866
if not keep_old:
5967
shutil.rmtree(IRODS_SSL_DIR,ignore_errors=True)
60-
print("Generating new '{}'. This may take a while.".format(IRODS_SSL_DIR), file=sys.stderr)
61-
ssl_dir_files = create_ssl_dir()
62-
print('ssl_dir_files=', ssl_dir_files)
68+
dh_strong_primes = '-q' not in options
69+
wait_warning = (' This may take a while.' if dh_strong_primes else '')
70+
print("Generating new '{}'.{}".format(IRODS_SSL_DIR, wait_warning), file = sys.stderr)
71+
ssl_dir_files = create_ssl_dir(use_strong_primes_for_dh_generation = dh_strong_primes)
72+
print('ssl_dir_files=', ssl_dir_files, file = sys.stderr)
6373

6474
if __name__ == '__main__':
6575
import getopt
66-
opt, arg_list = getopt.getopt(sys.argv[1:],'x:fh:k')
76+
opt, arg_list = getopt.getopt(sys.argv[1:],'x:fh:kq')
6777
opt_lookup = dict(opt)
78+
6879
ext = opt_lookup.get('-x','')
6980
if ext:
7081
ext = '.' + ext.lstrip('.')

0 commit comments

Comments
 (0)