comparison roundup/scripts/roundup_server.py @ 5356:91954be46a66

A real fix for the problem where: import random would result in every call to random() returning the same value in the web interface. While cgi/client.py:Client::__init.py__ was calling random.seed(), on most systems random was SystemRandom and not the default random. As a result the random as you would get from: import random was never being seeded. I added a function to access and seed the random bound instance of random.Random that is called during init. This fixes all three places where I saw the broken randomness. It should also fix: http://psf.upfronthosting.co.za/roundup/meta/issue644 I also removed the prior code that would bail if systemRandom was not available.
author John Rouillard <rouilj@ieee.org>
date Sun, 08 Jul 2018 11:34:42 -0400
parents 66a17c80e035
children 64b05e24dbd8 8e3df461d316
comparison
equal deleted inserted replaced
5355:f3446541e72b 5356:91954be46a66
86 MULTIPROCESS_TYPES.append("fork") 86 MULTIPROCESS_TYPES.append("fork")
87 DEFAULT_MULTIPROCESS = MULTIPROCESS_TYPES[-1] 87 DEFAULT_MULTIPROCESS = MULTIPROCESS_TYPES[-1]
88 88
89 def auto_ssl(): 89 def auto_ssl():
90 print _('WARNING: generating temporary SSL certificate') 90 print _('WARNING: generating temporary SSL certificate')
91 import OpenSSL 91 import OpenSSL, random
92
93 try:
94 # Use the cryptographic source of randomness if available
95 from random import SystemRandom
96 random=SystemRandom()
97 except ImportError:
98 raise
99 from random import Random
100 random=Random()
101
102 pkey = OpenSSL.crypto.PKey() 92 pkey = OpenSSL.crypto.PKey()
103 pkey.generate_key(OpenSSL.crypto.TYPE_RSA, 768) 93 pkey.generate_key(OpenSSL.crypto.TYPE_RSA, 768)
104 cert = OpenSSL.crypto.X509() 94 cert = OpenSSL.crypto.X509()
105 cert.set_serial_number(random.randint(0, sys.maxint)) 95 cert.set_serial_number(random.randint(0, sys.maxint))
106 cert.gmtime_adj_notBefore(0) 96 cert.gmtime_adj_notBefore(0)

Roundup Issue Tracker: http://roundup-tracker.org/