

@classmethod
def initialize(cls, path, name, begin=None, cluster_id=None):
    '\n        Generate new private/public key pair and self-sign, then store in given\n        directory.\n\n        :param FilePath path: Directory where private key and certificate are\n            stored.\n        :param bytes name: The name of the cluster. This is used as the\n            subject and issuer identities of the generated root certificate.\n        :param datetime begin: The datetime from which the generated\n            certificate should be valid.\n        :param UUID cluster_id: The unique identifier of the cluster for which\n            to generate the key and certificate.  If not given, a random\n            identifier will be generated.\n\n        :return RootCredential: Initialized certificate authority.\n        '
    if (cluster_id is None):
        cluster_id = uuid4()
    dn = DistinguishedName(commonName=name, organizationalUnitName=bytes(cluster_id))
    keypair = flocker_keypair()
    request = keypair.keypair.requestObject(dn)
    serial = os.urandom(16).encode(b'hex')
    serial = int(serial, 16)
    certificate = create_certificate_authority(keypair.keypair, dn, request, serial, EXPIRY_20_YEARS, b'sha256', start=begin)
    credential = FlockerCredential(path=path, keypair=keypair, certificate=certificate)
    credential.write_credential_files(AUTHORITY_KEY_FILENAME, AUTHORITY_CERTIFICATE_FILENAME)
    instance = cls(credential=credential)
    return instance

dataset/ETHPy150Open ClusterHQ/flocker/flocker/ca/_ca.py RootCredential.initialize/original