x509.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:Intranet-Penetration 作者: yuxiaokui 项目源码 文件源码
def _build_x509_name(self, x509_name):
        count = self._backend._lib.X509_NAME_entry_count(x509_name)
        attributes = []
        for x in range(count):
            entry = self._backend._lib.X509_NAME_get_entry(x509_name, x)
            obj = self._backend._lib.X509_NAME_ENTRY_get_object(entry)
            assert obj != self._backend._ffi.NULL
            data = self._backend._lib.X509_NAME_ENTRY_get_data(entry)
            assert data != self._backend._ffi.NULL
            buf = self._backend._ffi.new("unsigned char **")
            res = self._backend._lib.ASN1_STRING_to_UTF8(buf, data)
            assert res >= 0
            assert buf[0] != self._backend._ffi.NULL
            buf = self._backend._ffi.gc(
                buf, lambda buf: self._backend._lib.OPENSSL_free(buf[0])
            )
            value = self._backend._ffi.buffer(buf[0], res)[:].decode('utf8')
            oid = self._obj2txt(obj)
            attributes.append(
                x509.NameAttribute(
                    x509.ObjectIdentifier(oid), value
                )
            )

        return x509.Name(attributes)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号