Skip to content

Commit

Permalink
STNDS-508: Add validator for eIDAS LegalPerson OrgId (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
CBonnell authored May 14, 2024
1 parent 258936c commit aa66941
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkilint/etsi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def create_validators(certificate_type: CertificateType) -> List[validation.Vali
subject_validators = [
en_319_412_1.LegalPersonOrganizationIdentifierValidator(),
en_319_412_1.NaturalPersonIdentifierValidator(),
en_319_412_1.EidasLegalPersonIdentifierValidator(),
organization_id.OrganizationIdentifierLeiValidator(),
]

Expand Down
56 changes: 56 additions & 0 deletions pkilint/etsi/en_319_412_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,62 @@ def validate(self, node):
return validation.ValidationResult(self, node, findings)


class EidasLegalPersonIdentifierValidator(validation.Validator):
"""
LEG-5.1.6-03: Any organizationIdentifier attribute present in the subject field of the certificate shall
comply with the content requirement specified for the eIDAS LegalPersonIdentifier attribute.
From eIDAS SAML Attribute Profile v1.2 Final, section 2.5:
- The Unique Identifier MUST NOT contain any whitespace.
- The Unique Identifier MUST NOT exceed a total of 256 characters.
"""
VALIDATION_EIDAS_LEGAL_PERSON_IDENTIFIER_WHITESPACE_PRESENT = validation.ValidationFinding(
validation.ValidationFindingSeverity.ERROR,
'etsi.en_319_412_1.leg-5.1.6-03.eidas_legal_person_identifier_whitespace_present'
)

VALIDATION_EIDAS_LEGAL_PERSON_IDENTIFIER_TOO_LONG = validation.ValidationFinding(
validation.ValidationFindingSeverity.ERROR,
'etsi.en_319_412_1.leg-5.1.6-03.eidas_legal_person_identifier_too_long'
)

_MAX_LENGTH = 256

def __init__(self):
super().__init__(
validations=[
self.VALIDATION_EIDAS_LEGAL_PERSON_IDENTIFIER_WHITESPACE_PRESENT,
self.VALIDATION_EIDAS_LEGAL_PERSON_IDENTIFIER_TOO_LONG,
],
pdu_class=x520_name.X520OrganizationIdentifier
)

def match(self, node):
# noinspection PyTypeChecker
return super().match(node) and _cert_has_semantics_id(
en_319_412_1.id_etsi_qcs_SemanticsId_eIDASLegal,
node.document
)

def validate(self, node):
value = str(node.child[1].pdu)

if any(c.isspace() for c in value):
raise validation.ValidationFindingEncountered(
self.VALIDATION_EIDAS_LEGAL_PERSON_IDENTIFIER_WHITESPACE_PRESENT,
f'Whitespace present in organization identifier: "{value}"'
)

value_len = len(value)

if value_len > self._MAX_LENGTH:
raise validation.ValidationFindingEncountered(
self.VALIDATION_EIDAS_LEGAL_PERSON_IDENTIFIER_TOO_LONG,
f'Organization identifier "{value}" ({value_len} characters) exceeds maximum length of '
f'{self._MAX_LENGTH} characters'
)


class NameRegistrationAuthoritiesValidatorBase(validation.Validator):
def __init__(
self,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-----BEGIN CERTIFICATE-----
MIIIQTCCBimgAwIBAgIQVZHNRxiZp9LoR1nlajD1DDANBgkqhkiG9w0BAQsFADCB
oTELMAkGA1UEBhMCR1IxNjA0BgNVBAoTLUhFTExFTklDIEVYQ0hBTkdFUyAtIEFU
SEVOUyBTVE9DSyBFWENIQU5HRSBTQTEvMC0GA1UEAxMmQVRIRVggUXVhbGlmaWVk
IFdFQiBDZXJ0aWZpY2F0ZXMgQ0EtRzMxDzANBgNVBAcTBkF0aGVuczEYMBYGA1UE
YRMPVkFURUwtMDk5NzU1MTA4MB4XDTI0MDQxMTE0MTY1NVoXDTI1MDQxMTE0MTY1
NVowggG7MQswCQYDVQQGEwJHUjE2MDQGA1UEChMtSEVMTEVOSUMgRVhDSEFOR0VT
IC0gQVRIRU5TIFNUT0NLIEVYQ0hBTkdFIFNBMYIBDjCCAQoGA1UEYROCAQFhYWFh
YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh
YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhY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BYB8cTgucNAGUBur
3ku6KO8fHcxpO3zLvA9I6LNhOmvLX24dPRprFd8uK+FiciNxbA3CjDGNUtJUErRM
G8RRUXYPAM0tF9fZpKm3SurevG01yO8m/AcmsMuKjzJ9LIle7ioZtDc7C64ldoQ+
IEA1QRyRo8qDml25rgvC3vTyQ4bngTunPPfEsSO04NT71G7va3DyV/VGVbCnlkj7
sIHIPRY=
-----END CERTIFICATE-----

node_path,validator,severity,code,message
certificate.tbsCertificate.subject.rdnSequence.2.0.value.x520OrganizationIdentifier,EidasLegalPersonIdentifierValidator,ERROR,etsi.en_319_412_1.leg-5.1.6-03.eidas_legal_person_identifier_too_long,"Organization identifier ""aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"" (257 characters) exceeds maximum length of 256 characters"
certificate.tbsCertificate.extensions.6.extnValue.subjectKeyIdentifier,SubjectKeyIdentifierValidator,INFO,pkix.subject_key_identifier_method_1_identified,
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
-----BEGIN CERTIFICATE-----
MIIHSTCCBTGgAwIBAgIQVZHNRxiZp9LoR1nlajD1DDANBgkqhkiG9w0BAQsFADCB
oTELMAkGA1UEBhMCR1IxNjA0BgNVBAoTLUhFTExFTklDIEVYQ0hBTkdFUyAtIEFU
SEVOUyBTVE9DSyBFWENIQU5HRSBTQTEvMC0GA1UEAxMmQVRIRVggUXVhbGlmaWVk
IFdFQiBDZXJ0aWZpY2F0ZXMgQ0EtRzMxDzANBgNVBAcTBkF0aGVuczEYMBYGA1UE
YRMPVkFURUwtMDk5N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owxjVLSVBK0TBvEUVF2DwDN
LRfX2aSpt0rq3rxtNcjvJvwHJrDLio8yfSyJXu4qGbQ3OwuuJXaEPiBANUEckaPK
g5pdua4Lwt708kOG54E7pzz3xLEjtODU+9Ru72tw8lf1RlWwp5ZI+7CByD0W
-----END CERTIFICATE-----

node_path,validator,severity,code,message
certificate.tbsCertificate.subject.rdnSequence.2.0.value.x520OrganizationIdentifier,EidasLegalPersonIdentifierValidator,ERROR,etsi.en_319_412_1.leg-5.1.6-03.eidas_legal_person_identifier_whitespace_present,"Whitespace present in organization identifier: ""VATEL-09975 5108"""
certificate.tbsCertificate.extensions.6.extnValue.subjectKeyIdentifier,SubjectKeyIdentifierValidator,INFO,pkix.subject_key_identifier_method_1_identified,

0 comments on commit aa66941

Please sign in to comment.