Skip to content

Commit cdd47ab

Browse files
committed
In testing don't depend on strong primes for DH param generation.
1 parent 27aa4cb commit cdd47ab

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

irods/test/login_auth_test.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -513,15 +513,12 @@ def test_ssl_with_server_verify_set_to_none_281(self):
513513
with open(env_file) as env_file_handle:
514514
env = json.load( env_file_handle )
515515
my_ssl_directory = os.path.expanduser("~/some")
516-
create_ssl_dir(ssl_dir = my_ssl_directory)
516+
# Elect for efficiency in DH param generation, eg. when setting up for testing.
517+
create_ssl_dir(ssl_dir = my_ssl_directory, use_strong_primes_for_dh_generation = False)
517518
keys_to_update = {key:value.replace("/etc/irods/ssl",my_ssl_directory)
518519
for key,value in env.items() if type(value) is str and value.startswith("/etc/irods/ssl")}
519520
keys_to_update["irods_ssl_verify_server"] = "none"
520521
env.update( keys_to_update )
521-
# --- TODO: remove these lines
522-
import pprint
523-
print ("Updated = \n", pprint.pformat(env))
524-
# ---
525522
with open(env_file,'w') as f:
526523
json.dump(env,f)
527524
with helpers.make_session() as session:

irods/test/setupssl.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ 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', ssl_dir = ''):
28+
29+
def create_ssl_dir(irods_key_path = 'irods.key', ssl_dir = '', use_strong_primes_for_dh_generation = True):
2930
ssl_dir = ssl_dir or IRODS_SSL_DIR
3031
save_cwd = os.getcwd()
3132
silent_run = { 'shell': True, 'stderr' : PIPE, 'stdout' : PIPE }
@@ -39,9 +40,13 @@ def create_ssl_dir(irods_key_path = 'irods.key', ssl_dir = ''):
3940
with open("/dev/null","wb") as dev_null:
4041
if 0 == create_server_cert(process_output = dev_null, irods_key_path = irods_key_path):
4142
if not keep_old:
42-
# TODO : verify SSL still works ok in iRODS with -dsaparam
43-
# TODO : possibly drive use of -dsaparam from a global command switch eg. --params-for-test-only
44-
Popen('openssl dhparam -dsaparam -out dhparams.pem 4096',**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()
4550
return os.listdir(".")
4651
finally:
4752
os.chdir(save_cwd)
@@ -60,14 +65,17 @@ def test(options, args=()):
6065
if affirm[:1].lower() == 'y':
6166
if not keep_old:
6267
shutil.rmtree(IRODS_SSL_DIR,ignore_errors=True)
63-
print("Generating new '{}'. This may take a while.".format(IRODS_SSL_DIR), file=sys.stderr)
64-
ssl_dir_files = create_ssl_dir()
65-
print('ssl_dir_files=', ssl_dir_files,file=sys.stderr)
68+
dh_strong_primes = not options.has_key('-q')
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)
6673

6774
if __name__ == '__main__':
6875
import getopt
69-
opt, arg_list = getopt.getopt(sys.argv[1:],'x:fh:k')
76+
opt, arg_list = getopt.getopt(sys.argv[1:],'x:fh:kq')
7077
opt_lookup = dict(opt)
78+
7179
ext = opt_lookup.get('-x','')
7280
if ext:
7381
ext = '.' + ext.lstrip('.')

0 commit comments

Comments
 (0)