pyopenssl解析国密证书
获取算法名称
def get_signature_algorithm(self):
"""
Return the signature algorithm used in the certificate.
:return: The name of the algorithm.
:rtype: :py:class:`bytes`
:raises ValueError: If the signature algorithm is undefined.
.. versionadded:: 0.13
"""
algor = _lib.X509_get0_tbs_sigalg(self._x509)
nid = _lib.OBJ_obj2nid(algor.algorithm)
if nid == _lib.NID_undef:
# https://bugs.python.org/issue30502
# 这里用Python3.7 会找不到OBJ_obj2txt,换Python3.8或3.9就可以
buf = bytes(20)
if _lib.OBJ_obj2txt(bytes(buf), len(buf), algor.algorithm, 0) > 0:
return buf
raise ValueError("Undefined signature algorithm")
return _ffi.string(_lib.OBJ_nid2ln(nid))
修改后可以返回b'SM2-with-SM3'
转载:https://blog.csdn.net/javajiawei/article/details/116569515