Projekt

Obecné

Profil

« Předchozí | Další » 

Revize ca31a7f7

Přidáno uživatelem Stanislav Král před téměř 4 roky(ů)

Re #8575 - Fixed an issue where when creating an index file the valid_to field was passed instead of the revocation_date field

Zobrazit rozdíly:

src/services/crl/crl_service.py
1
import time
1
from datetime import datetime
2 2

  
3 3
from injector import inject
4 4

  
5 5
from src.dao.certificate_repository import CertificateRepository
6
from src.services.certificate_service import VALID_FROM_TO_DATE_FORMAT
7 6
from src.services.crl.ca_index_file_line_generator import create_index_file_revoked_line
8 7
from src.services.cryptography import CryptographyService
9 8

  
......
31 30
        for certificate in self.certificate_repository.get_all_revoked_by(ca_id):
32 31
            # extract the complete subject information and not_after date field
33 32
            subject, _, not_after = self.cryptography_service.parse_cert_pem(certificate.pem_data)
33

  
34 34
            line = create_index_file_revoked_line(certificate,
35 35
                                                  subject,
36
                                                  # parse valid_to date to a date struct
37
                                                  time.strptime(certificate.valid_to, VALID_FROM_TO_DATE_FORMAT),
36
                                                  # parse revocation date from unix timestamp to struct_time
37
                                                  datetime.utcfromtimestamp(int(certificate.revocation_date)).timetuple(),
38 38
                                                  not_after)
39 39

  
40 40
            # append it to the list of lines
tests/integration_tests/services/crl_service_test.py
1 1
import time
2
from datetime import datetime
2 3

  
3 4
from src.model.subject import Subject
4 5
from src.services.certificate_service import VALID_FROM_TO_DATE_FORMAT
......
35 36
                                                  root_ca_private_key)
36 37

  
37 38
    # create another CA
38
    bar_baz_ca = certificate_service_unique.create_ca(inter_ca_private_key, Subject(common_name="BarBaz CA"),
39
    certificate_service_unique.create_ca(inter_ca_private_key, Subject(common_name="BarBaz CA"),
39 40
                                                      root_ca_cert,
40 41
                                                      root_ca_private_key)
41 42

  
......
56 57
    # create index of revoked certificates
57 58
    out = crl_service_unique.create_revoked_index(root_ca_cert.certificate_id)
58 59

  
60
    # fetch certificates in order to update the revocation_date fields
61
    foo_ca = certificate_service_unique.get_certificate(foo_ca.certificate_id)
62
    bar_ca = certificate_service_unique.get_certificate(bar_ca.certificate_id)
63
    baz_cert = certificate_service_unique.get_certificate(baz_cert.certificate_id)
64

  
59 65
    # convert revoked date fields (revoked date fields change with each test run)
60 66
    revoked_dates = [
61
        convert_date_to_ca_index_format(cryptography_service.parse_cert_pem(foo_ca.pem_data)[2]),
62
        convert_date_to_ca_index_format(cryptography_service.parse_cert_pem(bar_ca.pem_data)[2]),
63
        convert_date_to_ca_index_format(cryptography_service.parse_cert_pem(baz_cert.pem_data)[2]),
67
        convert_date_to_ca_index_format(datetime.utcfromtimestamp(int(foo_ca.revocation_date)).timetuple()),
68
        convert_date_to_ca_index_format(datetime.utcfromtimestamp(int(bar_ca.revocation_date)).timetuple()),
69
        convert_date_to_ca_index_format(datetime.utcfromtimestamp(int(baz_cert.revocation_date)).timetuple()),
64 70
    ]
65 71

  
66 72
    # convert valid_to date fields (expiration date fields change with each test run)

Také k dispozici: Unified diff