You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having a problem when the TbsCertList.dump() gets called, and it's quite confusing as to why. The problem is that when that function is called, it takes a very long time for it to complete (we're talking minutes). We need the dump method because it is used in the verification process of a CRL.
Here is some example code to reproduce the problem and a fix which works by rebuilding the CertificateList object (could you explain why this works?):
I'm also using python 3.6.8
I attached the source crl file as a .txt, but you can rename it to source.crl (same with the python file)
import os
import asn1crypto.core
from asn1crypto import crl
from asn1crypto.crl import TbsCertList, CertificateList
def fix_certificate_list(in_list):
''' some certificate lists take a long time to dump(), but this appears to fix the problem '''
tbslist = TbsCertList()
if not isinstance(in_list['tbs_cert_list']['version'], asn1crypto.core.Void):
tbslist['version'] = in_list['tbs_cert_list']['version']
tbslist['signature'] = in_list['tbs_cert_list']['signature']
tbslist['issuer'] = in_list['tbs_cert_list']['issuer']
tbslist['this_update'] = in_list['tbs_cert_list']['this_update']
if not isinstance(in_list['tbs_cert_list']['next_update'], asn1crypto.core.Void):
tbslist['next_update'] = in_list['tbs_cert_list']['next_update']
if not isinstance(in_list['tbs_cert_list']['revoked_certificates'], asn1crypto.core.Void):
tbslist['revoked_certificates'] = in_list['tbs_cert_list']['revoked_certificates']
if not isinstance(in_list['tbs_cert_list']['crl_extensions'], asn1crypto.core.Void):
tbslist['crl_extensions'] = in_list['tbs_cert_list']['crl_extensions']
outlist = CertificateList()
outlist['tbs_cert_list'] = tbslist
outlist['signature_algorithm'] = in_list['signature_algorithm']
outlist['signature'] = in_list['signature']
return outlist
print("load")
certificate_list = None
with open('source.crl', 'rb') as f:
slow_list = crl.CertificateList.load(f.read())
fast_list = fix_certificate_list(slow_list)
print("dump fast_list")
print(len(fast_list['tbs_cert_list'].dump()))
print("done")
print("dump slow_list")
print(len(slow_list['tbs_cert_list'].dump()))
print("done")
I am having a problem when the TbsCertList.dump() gets called, and it's quite confusing as to why. The problem is that when that function is called, it takes a very long time for it to complete (we're talking minutes). We need the dump method because it is used in the verification process of a CRL.
Here is some example code to reproduce the problem and a fix which works by rebuilding the CertificateList object (could you explain why this works?):
I'm also using python 3.6.8
I attached the source crl file as a .txt, but you can rename it to source.crl (same with the python file)
crl_dump_demo.py.txt
source.crl.txt
The text was updated successfully, but these errors were encountered: