'Write PEM encoded certificate and private key files for this credential
instance.
:param bytes key_filename: The name of the private key file to write,
e.g. "cluster.key"
:param bytes certificate_filename: The name of the certificate file to
write, e.g. "cluster.crt"'

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 = 384
    try:
        with os.fdopen(os.open(cert_path.path, ((os.O_WRONLY | os.O_CREAT) | os.O_EXCL), mode), '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), 'w') as key_file:
                key_file.write(self.keypair.keypair.dump(crypto.FILETYPE_PEM))
        except (IOError, OSError) as e:
            (code, failure) = e
            raise PathError('Unable    to    write    private    key    file.', e.filename, code, failure)
    except (IOError, OSError) as e:
        (code, failure) = e
        raise PathError('Unable    to    write    certificate    file.', e.filename, code, failure)
    finally:
        os.umask(original_umask)
