Changeset 2811 for trunk/server
- Timestamp:
- Dec 16, 2016, 1:05:55 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/server/fedora/config/etc/httpd/export-scripts-certs ¶
r2791 r2811 25 25 vhosts.sort(key=lambda (dn, vhost): vhost['scriptsVhostName']) 26 26 27 cert_filenames = set() 28 27 29 def conf(vhost): 28 30 name, = vhost['scriptsVhostName'] … … 32 34 33 35 certs = ''.join('-----BEGIN CERTIFICATE-----\n' + '\n'.join(textwrap.wrap(cert, 64)) + '\n-----END CERTIFICATE-----\n' for cert in certs.split()) 34 cert_filename = os.path.join(CERTS_DIR, base64.urlsafe_b64encode(hashlib.sha256(certs).digest()).strip() + '.pem') 35 if not os.path.exists(cert_filename): 36 with open(cert_filename + '.new', 'w') as cert_file: 36 cert_filename = base64.urlsafe_b64encode(hashlib.sha256(certs).digest()).strip() + '.pem' 37 cert_filenames.add(cert_filename) 38 cert_path = os.path.join(CERTS_DIR, cert_filename) 39 if not os.path.exists(cert_path): 40 with open(cert_path + '.new', 'w') as cert_file: 37 41 cert_file.write(certs) 38 os.rename(cert_ filename + '.new', cert_filename)42 os.rename(cert_path + '.new', cert_path) 39 43 40 44 for port in 443, 444: … … 47 51 if port == 444: 48 52 yield '\tInclude conf.d/vhosts-common-ssl-cert.conf\n' 49 yield '\tSSLCertificateFile {}\n'.format(cert_ filename)53 yield '\tSSLCertificateFile {}\n'.format(cert_path) 50 54 yield '\tSSLCertificateKeyFile {}\n'.format(os.path.join('/etc/pki/tls/private', key_filename)) 51 55 yield '</VirtualHost>\n' … … 55 59 vhosts_file.write(''.join(l for dn, vhost in vhosts for l in conf(vhost))) 56 60 os.rename(os.path.join(CERTS_DIR, 'vhosts.conf.new'), os.path.join(CERTS_DIR, 'vhosts.conf')) 61 62 for filename in os.listdir(CERTS_DIR): 63 if filename.endswith('.pem') and filename not in cert_filenames: 64 os.remove(os.path.join(CERTS_DIR, filename))
Note: See TracChangeset
for help on using the changeset viewer.