def write_credential_files(self, key_filename, certificate_filename):
        key_path = self.path.child(key_filename)
        cert_path = self.path.child(certificate_filename)
        original_umask = os.umask(0)
        mode = 0o600
        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)
Write PEM encoded certificate and private key files for this credential
dataset/ETHPy150Open ClusterHQ/flocker/flocker/ca/_ca.py/FlockerCredential.write_credential_files