从CRL中提取版本属性。

huangapple go评论66阅读模式
英文:

Extract version attribute from the CRL

问题

在提取如图所示的版本2时遇到问题

openssl crl -inform DER -text -noout -in CRL

从CRL中提取版本属性。

from cryptography.hazmat.backends import default_backend

def extract_crl_version(crl_file_path):
    with open(crl_file_path, "rb") as file:
        crl_data = file.read()

    crl = x509.load_der_x509_crl(crl_data, default_backend())

    crl_version = crl.version

    return crl_version

crl_file_path = "path/to/crl.crl"
crl_version = extract_crl_version(crl_file_path)
print("CRL版本:", crl_version)

这对我来说不起作用

错误: crl_version = crl.version AttributeError: 'CertificateRevocationList' 对象没有 'version' 属性

英文:

Facing issues while extracting the version 2 as shown in the image

openssl crl -inform DER -text -noout -in CRL

从CRL中提取版本属性。

from cryptography.hazmat.backends import default_backend

def extract_crl_version(crl_file_path):
    with open(crl_file_path, "rb") as file:
        crl_data = file.read()

    crl = x509.load_der_x509_crl(crl_data, default_backend())

    crl_version = crl.version

    return crl_version

crl_file_path = "path/to/crl.crl"
crl_version = extract_crl_version(crl_file_path)
print("CRL Version:", crl_version)

This is not working for me

ERROR: crl_version = crl.version
AttributeError: '_CertificateRevocationList' object has no attribute 'version'

答案1

得分: 1

在此URL中没有属性版本:
https://cryptography.io/en/3.4/x509/reference.html#x-509-crl-certificate-revocation-list-object

尝试打印crl的长度和

for r in crl:
    print(r.serial_number)
英文:

no attribute version. in this url:
https://cryptography.io/en/3.4/x509/reference.html#x-509-crl-certificate-revocation-list-object

try print len(crl) and

for r in crl:
    print(r.serial_number)

huangapple
  • 本文由 发表于 2023年6月2日 06:48:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76386163.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定