Esempio n. 1
0
    def __init__(self, root_dir, cert_globals, fqdn):
        ca_globals = {}
        ca_globals['verbose'] = cert_globals['verbose']

        self.ca = CA(root_dir, ca_globals, True)

        if not root_dir:
            if os.path.isdir(os.path.abspath(self.default_root_dir)):
                root_dir = os.path.abspath(self.default_root_dir)
            else:
                try:
                    self.ca.CheckForPopulatedCAdirectory()

                    root_dir = self.ca.getIntermediateDirectory()
                except FileNotFoundError as e:
                    root_dir = Certificate.default_root_dir

        for key, value in self.subdirs.items():
            value['path'] = "{}/{}".format(root_dir, value['path'])

        Path(self.getPrivatePath()).mkdir(parents=True, exist_ok=True)
        Path(self.getCertsPath()).mkdir(parents=True, exist_ok=True)
        Path(self.getCSRPath()).mkdir(parents=True, exist_ok=True)

        self.fqdn = fqdn
Esempio n. 2
0
def create_intermediate_certificate():
    """
      Create a signed intermediate crtificate.
    """
    try:
        ca = CA(rootDir, ca_globals)
        ca.createIntermediateCertificate()
    except FileNotFoundError as e:
        print(e)
Esempio n. 3
0
def ca_create_root_certificate():
    """
      Create the root certificate for the CA.
    """
    try:
        ca = CA(rootDir, ca_globals)
        ca.createRootCertificate()
    except FileNotFoundError as e:
        print(e)
Esempio n. 4
0
def ca_create_intermediate_key():
    """
      Create a private key for the usage of the CA.
    """
    try:
        ca = CA(rootDir, ca_globals)
        ca.createIntermediateKey()
    except FileExistsError as e:
        print(e)
Esempio n. 5
0
def sign_csr(fqdn):
    try:
        ca = CA(rootDir, ca_globals, fqdn)

        config = ca.getIntermediateConfigName()
        csr = ca.getCSRName()
        certificate = ca.getCertificateName()

        ca.signCSR(config, csr, certificate)
    except FileNotFoundError as e:
        print(e)
Esempio n. 6
0
def ca_init(serial_number, root_config_file, intermediate_config_file):
    """
      Create a root directory if it does not exist and populate it. The
      init command requires one parameter:\n

      Args:\n
          CONFIG_FILE: path to the the configuration file of the root CA.
    """
    try:
        ca = CA(rootDir, ca_globals, missing_ca_dir_okay=True)
        ca.init(root_config_file, intermediate_config_file, serial_number)
    except FileNotFoundError as e:
        print(e)
Esempio n. 7
0
def create_domain_key(fqdn):
    try:
        ca = CA(rootDir, ca_globals)
        ca.createDomainKey(fqdn)
    except FileNotFoundError as e:
        print(e)