Skip to content

Commit 9b0a2fd

Browse files
committed
Remove from-crl
1 parent 1517ccc commit 9b0a2fd

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

credentials/generate_revocation_set.py

+9-21
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
# python ./credentials/generate-revocation-set.py --help
2222

2323
import base64
24-
import dataclasses
2524
import json
2625
import logging
2726
import os
2827
import subprocess
2928
import sys
3029
import unittest
3130
from enum import Enum
31+
import dataclasses
3232
from typing import Optional
3333

3434
import click
@@ -53,7 +53,6 @@
5353
class RevocationType(Enum):
5454
CRL = 1
5555

56-
5756
class CertVerificationResult(Enum):
5857
SUCCESS = 1
5958
SKID_NOT_FOUND = 2
@@ -62,7 +61,6 @@ class CertVerificationResult(Enum):
6261
ISSUER_MISMATCH = 5
6362
AKID_MISMATCH = 6
6463

65-
6664
@dataclasses.dataclass
6765
class RevocationPoint:
6866
vid: int
@@ -79,7 +77,6 @@ class RevocationPoint:
7977
schemaVersion: int
8078
crlSignerDelegator: str
8179

82-
8380
@dataclasses.dataclass
8481
class RevocationSet:
8582
type: str
@@ -88,10 +85,10 @@ class RevocationSet:
8885
revoked_serial_numbers: [str]
8986
crl_signer_cert: str
9087
crl_signer_delegator: str = None
91-
88+
9289
def asDict(self):
9390
return dataclasses.asdict(self)
94-
91+
9592

9693
OID_VENDOR_ID = x509.ObjectIdentifier("1.3.6.1.4.1.37244.2.1")
9794
OID_PRODUCT_ID = x509.ObjectIdentifier("1.3.6.1.4.1.37244.2.2")
@@ -178,8 +175,7 @@ def is_self_signed_certificate(cert: x509.Certificate) -> bool:
178175
if result == CertVerificationResult.SUCCESS:
179176
return True
180177
else:
181-
logging.debug(
182-
f"Certificate with subject: {cert.subject.rfc4514_string()} is not a valid self-signed certificate. Result: {result.name}")
178+
logging.debug(f"Certificate with subject: {cert.subject.rfc4514_string()} is not a valid self-signed certificate. Result: {result.name}")
183179
return False
184180

185181

@@ -196,21 +192,18 @@ def validate_cert_chain(crl_signer: x509.Certificate, crl_signer_delegator: x509
196192
if crl_signer_delegator:
197193
result_signer = verify_cert(crl_signer, crl_signer_delegator)
198194
if not result_signer == CertVerificationResult.SUCCESS:
199-
logging.debug(
200-
f"Cannot verify certificate subject: {crl_signer.subject.rfc4514_string()} issued by certificate subject: {crl_signer_delegator.subject.rfc4514_string()}. Result: {result_signer.name}")
195+
logging.debug(f"Cannot verify certificate subject: {crl_signer.subject.rfc4514_string()} issued by certificate subject: {crl_signer_delegator.subject.rfc4514_string()}. Result: {result_signer.name}")
201196
return False
202197

203198
result_delegator = verify_cert(crl_signer_delegator, paa)
204199
if not result_delegator == CertVerificationResult.SUCCESS:
205-
logging.debug(
206-
f"Cannot verify certificate subject: {crl_signer_delegator.subject.rfc4514_string()} issued by certificate subject: {paa.subject.rfc4514_string()}. Result: {result.name}")
200+
logging.debug(f"Cannot verify certificate subject: {crl_signer_delegator.subject.rfc4514_string()} issued by certificate subject: {paa.subject.rfc4514_string()}. Result: {result.name}")
207201
return False
208202
return True
209203
else:
210204
result = verify_cert(crl_signer, paa)
211205
if not result == CertVerificationResult.SUCCESS:
212-
logging.debug(
213-
f"Cannot verify certificate subject: {crl_signer.subject.rfc4514_string()} issued by certificate subject: {paa.subject.rfc4514_string()}. Result: {result.name}")
206+
logging.debug(f"Cannot verify certificate subject: {crl_signer.subject.rfc4514_string()} issued by certificate subject: {paa.subject.rfc4514_string()}. Result: {result.name}")
214207
return False
215208
return True
216209

@@ -359,7 +352,6 @@ def fetch_crl_from_url(url: str, timeout: int) -> x509.CertificateRevocationList
359352
except Exception as e:
360353
logging.error('Failed to fetch a valid CRL', e)
361354

362-
363355
class DclClientInterface:
364356
'''
365357
An interface for interacting with DCLD.
@@ -606,7 +598,7 @@ def get_revocation_points(self) -> list[RevocationPoint]:
606598
'''
607599

608600
response = self.send_get_request(f"{self.rest_node_url}/dcl/pki/revocation-points")
609-
601+
610602
return [RevocationPoint(**r) for r in response["PkiRevocationDistributionPoint"]]
611603

612604
def get_revocation_points_by_skid(self, issuer_subject_key_id) -> list[RevocationPoint]:
@@ -674,8 +666,7 @@ def __init__(self, crls: [], dcl_certificates: [], revocation_points_response_fi
674666
logging.debug(f"Loading crls from {crls}")
675667
logging.debug(f"Loading revocation points response from {revocation_points_response_file}")
676668
self.crls = self.get_crls(crls)
677-
self.revocation_points = [RevocationPoint(**r)
678-
for r in json.load(revocation_points_response_file)["PkiRevocationDistributionPoint"]]
669+
self.revocation_points = [RevocationPoint(**r) for r in json.load(revocation_points_response_file)["PkiRevocationDistributionPoint"]]
679670
self.authoritative_certs = self.get_authoritative_certificates(dcl_certificates)
680671

681672
def get_lookup_key(self, certificate: x509.Certificate) -> str:
@@ -851,7 +842,6 @@ def get_crl_file(self,
851842
return crl
852843
return None
853844

854-
855845
@click.group()
856846
def cli():
857847
pass
@@ -995,7 +985,6 @@ def from_dcl(use_main_net_dcld: str, use_test_net_dcld: str, use_main_net_http:
995985
with open(output, 'w+') as outfile:
996986
json.dump([revocation.asDict() for revocation in revocation_set], outfile, indent=4)
997987

998-
999988
class TestRevocationSetGeneration(unittest.TestCase):
1000989
"""Test class for revocation set generation"""
1001990

@@ -1062,7 +1051,6 @@ def test_pai_revocation_set(self):
10621051
'test/revoked-attestation-certificates/revocation-sets/revocation-set-for-pai.json'
10631052
)
10641053

1065-
10661054
if __name__ == "__main__":
10671055
if len(sys.argv) > 1 and sys.argv[1] == 'test':
10681056
# Remove the 'test' argument and run tests

0 commit comments

Comments
 (0)