def WriteTrustedCert(self, dir):
        """
        Write this cert as trusted cert in the given dir.
        """

        base = self.cert.get_subject().get_hash()

        certPath = os.path.join(dir, "%s.0" % (base))

        fh = open(certPath, "w")
        fh.write(crypto.dump_certificate(crypto.FILETYPE_PEM, self.cert))
        fh.close()
    def WriteTrustedCert(self, dir):
        """
        Write this cert as trusted cert in the given dir.
        """

        base = self.cert.get_subject().get_hash()

        certPath = os.path.join(dir, "%s.0" % (base))

        fh = open(certPath, "w")
        fh.write(crypto.dump_certificate(crypto.FILETYPE_PEM, self.cert))
        fh.close()
    def Write(self, dir, basename, passphrase = None):
        """
        Write the cert out to dir, with base path of basename.
        """

        certPath = os.path.join(dir, "%s.cert.pem" %(basename))
        keyPath  = os.path.join(dir, "%s.key.pem" %(basename))

        fh = open(certPath, "w")
        fh.write(crypto.dump_certificate(crypto.FILETYPE_PEM, self.cert))
        fh.close()

        fh = open(keyPath, "w")

        if passphrase is None:
            fh.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, self.key))
        else:
            fh.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, self.key, "DES3", passphrase))
        fh.close()

        return certPath, keyPath
    def Write(self, dir, basename, passphrase=None):
        """
        Write the cert out to dir, with base path of basename.
        """

        certPath = os.path.join(dir, "%s.cert.pem" % (basename))
        keyPath = os.path.join(dir, "%s.key.pem" % (basename))

        fh = open(certPath, "w")
        fh.write(crypto.dump_certificate(crypto.FILETYPE_PEM, self.cert))
        fh.close()

        fh = open(keyPath, "w")

        if passphrase is None:
            fh.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, self.key))
        else:
            fh.write(
                crypto.dump_privatekey(crypto.FILETYPE_PEM, self.key, "DES3",
                                       passphrase))
        fh.close()

        return certPath, keyPath