@@ -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
6774if __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