コード例 #1
0
ファイル: X509.py プロジェクト: timb-machine-mirrors/MEAT
    def save(self, filename, format=FORMAT_PEM):
        # type: (AnyStr, int) -> int
        """
        Saves X.509 certificate request to a file. Default output
        format is PEM.

        :param filename: Name of the file the request will be saved to.

        :param format: Controls what output format is used to save the
                       request. Either FORMAT_PEM or FORMAT_DER to save
                       in PEM or DER format. Raises ValueError if an
                       unknown format is used.

        :return: 1 for success, 0 for failure.
                 The error code can be obtained by ERR_get_error.
        """
        with BIO.openfile(filename, 'wb') as bio:
            if format == FORMAT_PEM:
                return m2.x509_req_write_pem(bio.bio_ptr(), self.req)
            elif format == FORMAT_DER:
                return m2.i2d_x509_req_bio(bio.bio_ptr(), self.req)
            else:
                raise ValueError(
                    "Unknown filetype. Must be either FORMAT_DER or FORMAT_PEM"
                )
コード例 #2
0
    def save(self, filename, format=FORMAT_PEM):
        """
        Saves X.509 certificate request to a file. Default output
        format is PEM.

        @type filename: string
        @param filename: Name of the file the request will be saved to.
        @type format: int
        @param format: Controls what output format is used to save the request.
        Either FORMAT_PEM or FORMAT_DER to save in PEM or DER format.
        Raises ValueError if an unknown format is used.
        """
        bio = BIO.openfile(filename, 'wb')
        if format == FORMAT_PEM:
            return m2.x509_req_write_pem(bio.bio_ptr(), self.req)
        elif format == FORMAT_DER:
            return m2.i2d_x509_req_bio(bio.bio_ptr(), self.req)
        else:
            raise ValueError(
                "Unknown filetype. Must be either FORMAT_DER or FORMAT_PEM")
コード例 #3
0
ファイル: X509.py プロジェクト: rodrigc/m2crypto
    def save(self, filename, format=FORMAT_PEM):
        """
        Saves X.509 certificate request to a file. Default output
        format is PEM.

        @type filename: string
        @param filename: Name of the file the request will be saved to.
        @type format: int
        @param format: Controls what output format is used to save the request.
        Either FORMAT_PEM or FORMAT_DER to save in PEM or DER format.
        Raises ValueError if an unknown format is used.
        """
        bio = BIO.openfile(filename, 'wb')
        if format == FORMAT_PEM:
            return m2.x509_req_write_pem(bio.bio_ptr(), self.req)
        elif format == FORMAT_DER:
            return m2.i2d_x509_req_bio(bio.bio_ptr(), self.req)
        else:
            raise ValueError(
                "Unknown filetype. Must be either FORMAT_DER or FORMAT_PEM")
コード例 #4
0
ファイル: X509.py プロジェクト: mcepl/M2Crypto
    def save(self, filename, format=FORMAT_PEM):
        # type: (AnyStr, int) -> int
        """
        Saves X.509 certificate request to a file. Default output
        format is PEM.

        :param filename: Name of the file the request will be saved to.

        :param format: Controls what output format is used to save the
                       request. Either FORMAT_PEM or FORMAT_DER to save
                       in PEM or DER format. Raises ValueError if an
                       unknown format is used.

        :return: 1 for success, 0 for failure.
                 The error code can be obtained by ERR_get_error.
        """
        with BIO.openfile(filename, 'wb') as bio:
            if format == FORMAT_PEM:
                return m2.x509_req_write_pem(bio.bio_ptr(), self.req)
            elif format == FORMAT_DER:
                return m2.i2d_x509_req_bio(bio.bio_ptr(), self.req)
            else:
                raise ValueError(
                    "Unknown filetype. Must be either FORMAT_DER or FORMAT_PEM")
コード例 #5
0
 def save_pem(self, filename):
     # type: (AnyStr) -> int
     with BIO.openfile(filename, 'wb') as bio:
         return m2.x509_req_write_pem(bio.bio_ptr(), self.req)
コード例 #6
0
 def as_pem(self):
     # type: () -> bytes
     buf = BIO.MemoryBuffer()
     m2.x509_req_write_pem(buf.bio_ptr(), self.req)
     return buf.read_all()
コード例 #7
0
 def save_pem(self, filename):
     bio = BIO.openfile(filename, 'wb')
     return m2.x509_req_write_pem(bio.bio_ptr(), self.req)
コード例 #8
0
ファイル: X509.py プロジェクト: mcepl/M2Crypto
 def save_pem(self, filename):
     # type: (AnyStr) -> int
     with BIO.openfile(filename, 'wb') as bio:
         return m2.x509_req_write_pem(bio.bio_ptr(), self.req)
コード例 #9
0
ファイル: X509.py プロジェクト: mcepl/M2Crypto
 def as_pem(self):
     # type: () -> bytes
     buf = BIO.MemoryBuffer()
     m2.x509_req_write_pem(buf.bio_ptr(), self.req)
     return buf.read_all()
コード例 #10
0
ファイル: X509.py プロジェクト: rodrigc/m2crypto
 def save_pem(self, filename):
     bio = BIO.openfile(filename, 'wb')
     return m2.x509_req_write_pem(bio.bio_ptr(), self.req)