def GenerateNewSslCert(new_cert,
                       cert_filename,
                       serial_no,
                       log_msg,
                       uid=-1,
                       gid=-1):
    """Creates a new server SSL certificate and backups the old one.

  @type new_cert: boolean
  @param new_cert: whether a new certificate should be created
  @type cert_filename: string
  @param cert_filename: filename of the certificate file
  @type serial_no: int
  @param serial_no: serial number of the certificate
  @type log_msg: string
  @param log_msg: log message to be written on certificate creation
  @type uid: int
  @param uid: the user ID of the user who will be owner of the certificate file
  @type gid: int
  @param gid: the group ID of the group who will own the certificate file

  """
    cert_exists = os.path.exists(cert_filename)
    if new_cert or not cert_exists:
        if cert_exists:
            io.CreateBackup(cert_filename)

        logging.debug(log_msg)
        x509.GenerateSelfSignedSslCert(cert_filename,
                                       serial_no,
                                       uid=uid,
                                       gid=gid)
Exemple #2
0
def GenerateNewSslCert(new_cert, cert_filename, log_msg):
  """Creates a new SSL certificate and backups the old one.

  @type new_cert: boolean
  @param new_cert: whether a new certificate should be created
  @type cert_filename: string
  @param cert_filename: filename of the certificate file
  @type log_msg: string
  @param log_msg: log message to be written on certificate creation

  """
  cert_exists = os.path.exists(cert_filename)
  if new_cert or not cert_exists:
    if cert_exists:
      io.CreateBackup(cert_filename)

    logging.debug(log_msg)
    x509.GenerateSelfSignedSslCert(cert_filename)