

def write_credential_files(self, key_filename, certificate_filename):
    '\n        Write PEM encoded certificate and private key files for this credential\n        instance.\n\n        :param bytes key_filename: The name of the private key file to write,\n            e.g. "cluster.key"\n        :param bytes certificate_filename: The name of the certificate file to\n            write, e.g. "cluster.crt"\n        '
    key_path = self.path.child(key_filename)
    cert_path = self.path.child(certificate_filename)
    original_umask = os.umask(0)
    mode = 384
    try:
        with os.fdopen(os.open(cert_path.path, ((os.O_WRONLY | os.O_CREAT) | os.O_EXCL), mode), b'w') as cert_file:
            cert_file.write(self.certificate.dumpPEM())
        try:
            with os.fdopen(os.open(key_path.path, ((os.O_WRONLY | os.O_CREAT) | os.O_EXCL), mode), b'w') as key_file:
                key_file.write(self.keypair.keypair.dump(crypto.FILETYPE_PEM))
        except (IOError, OSError) as e:
            (code, failure) = e
            raise PathError(b'Unable to write private key file.', e.filename, code, failure)
    except (IOError, OSError) as e:
        (code, failure) = e
        raise PathError(b'Unable to write certificate file.', e.filename, code, failure)
    finally:
        os.umask(original_umask)

dataset/ETHPy150Open ClusterHQ/flocker/flocker/ca/_ca.py FlockerCredential.write_credential_files/original