Ejemplo n.º 1
0
    def create(cls, name, certificate):
        """
        Create a TLS CA. The certificate must be compatible with OpenSSL
        and be in PEM format. The certificate can be either a file with
        the Root CA, or a raw string starting with BEGIN CERTIFICATE, etc.
        When creating a TLS CA, you must also import the CA certificate. Once
        the CA is created, it is possible to import a different certificate to
        map to the CA if necessary.

        :param str name: name of root CA
        :param str,file certificate: The root CA contents
        :raises CreateElementFailed: failed to create the root CA
        :raises ValueError: if loading from file and no certificates present
        :raises IOError: cannot find specified file for certificate
        :rtype: TLSCertificateAuthority
        """
        json = {
            "name":
            name,
            "certificate":
            certificate if pem_as_string(certificate) else
            load_cert_chain(certificate)[0][1].decode("utf-8"),
        }

        return ElementCreator(cls, json)
Ejemplo n.º 2
0
 def create(cls, name, certificate):
     """
     Create a TLS CA. The certificate must be compatible with OpenSSL
     and be in PEM format. The certificate can be either a file with
     the Root CA, or a raw string starting with BEGIN CERTIFICATE, etc.
     When creating a TLS CA, you must also import the CA certificate. Once
     the CA is created, it is possible to import a different certificate to
     map to the CA if necessary.
     
     :param str name: name of root CA
     :param str,file certificate: The root CA contents
     :raises CreateElementFailed: failed to create the root CA
     :raises ValueError: if loading from file and no certificates present
     :raises IOError: cannot find specified file for certificate
     :rtype: TLSCertificateAuthority
     """
     json = {'name': name,
             'certificate': certificate if pem_as_string(certificate) else \
                 load_cert_chain(certificate)[0][1].decode('utf-8')}
     
     return ElementCreator(cls, json)