示例#1
0
文件: X509.py 项目: 0xkag/M2Crypto
    def save(self, filename, format=FORMAT_PEM):
        """
        Saves X.509 certificate to a file. Default output
        format is PEM.

        @type filename: string
        @param filename: Name of the file the cert will be saved to.
        @type format: int
        @param format: Controls what output format is used to save the cert.
        Either FORMAT_PEM or FORMAT_DER to save in PEM or DER format.
        Raises a ValueError if an unknow format is used.
        """
        bio = BIO.openfile(filename, 'wb')
        if format == FORMAT_PEM:
            return m2.x509_write_pem(bio.bio_ptr(), self.x509)
        elif format == FORMAT_DER:
            return m2.i2d_x509_bio(bio.bio_ptr(), self.x509)
        else:
            raise ValueError("Unknown filetype. Must be either FORMAT_PEM or FORMAT_DER")
示例#2
0
    def save(self, filename, format=FORMAT_PEM):
        """
        Saves X.509 certificate to a file. Default output
        format is PEM.

        @type filename: string
        @param filename: Name of the file the cert will be saved to.
        @type format: int
        @param format: Controls what output format is used to save the cert.
        Either FORMAT_PEM or FORMAT_DER to save in PEM or DER format.
        Raises a ValueError if an unknow format is used.
        """
        bio = BIO.openfile(filename, 'wb')
        if format == FORMAT_PEM:
            return m2.x509_write_pem(bio.bio_ptr(), self.x509)
        elif format == FORMAT_DER:
            return m2.i2d_x509_bio(bio.bio_ptr(), self.x509)
        else:
            raise ValueError(
                "Unknown filetype. Must be either FORMAT_PEM or FORMAT_DER")
示例#3
0
文件: X509.py 项目: 0xkag/M2Crypto
 def save_pem(self, filename):
     """
     save_pem
     """
     bio=BIO.openfile(filename, 'wb')
     return m2.x509_write_pem(bio.bio_ptr(), self.x509)
示例#4
0
文件: X509.py 项目: 0xkag/M2Crypto
 def as_pem(self):
     buf=BIO.MemoryBuffer()
     m2.x509_write_pem(buf.bio_ptr(), self.x509)
     return buf.read_all()
示例#5
0
 def save_pem(self, filename):
     """
     save_pem
     """
     bio = BIO.openfile(filename, 'wb')
     return m2.x509_write_pem(bio.bio_ptr(), self.x509)
示例#6
0
 def as_pem(self):
     buf = BIO.MemoryBuffer()
     m2.x509_write_pem(buf.bio_ptr(), self.x509)
     return buf.read_all()