You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

19 lines
714 B

  1. import os
  2. import shutil
  3. def copy_certificates(certificates, destination='/etc/ssl', domain='example.org'):
  4. private_key_folder = os.path.join(destination, 'private')
  5. if not os.path.exists(private_key_folder):
  6. os.makedirs(private_key_folder)
  7. private_key = os.path.join(private_key_folder, domain + '.key')
  8. shutil.copy2(certificates['key'], private_key)
  9. os.chmod(private_key, 0o600)
  10. certificates_folder = os.path.join(destination, 'certs')
  11. if not os.path.exists(certificates_folder):
  12. os.makedirs(certificates_folder)
  13. certificate = os.path.join(certificates_folder, domain + '.crt')
  14. shutil.copy2(certificates['crt'], certificate)
  15. os.chmod(certificate, 0o644)