Skip to content

Commit

Permalink
Merge pull request #220 from MatthiasValvekens/bugfix/attcertissuer-t…
Browse files Browse the repository at this point in the history
…agging-fix

Correct tagging in cms.AttCertIssuer
  • Loading branch information
wbond committed Jan 27, 2022
2 parents c6fe6cd + f9133f0 commit 6250ee4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion asn1crypto/cms.py
Expand Up @@ -273,7 +273,7 @@ class V2Form(Sequence):
class AttCertIssuer(Choice):
_alternatives = [
('v1_form', GeneralNames),
('v2_form', V2Form, {'explicit': 0}),
('v2_form', V2Form, {'implicit': 0}),
]


Expand Down
Binary file added tests/fixtures/example-attr-cert.der
Binary file not shown.
12 changes: 12 additions & 0 deletions tests/test_cms.py
Expand Up @@ -926,6 +926,18 @@ def test_bad_teletex_inside_pkcs7(self):
content['certificates'][0].chosen['tbs_certificate']['subject'].native
)

def test_parse_attribute_cert(self):
# regression test for tagging issue in AttCertIssuer

with open(os.path.join(fixtures_dir, 'example-attr-cert.der'), 'rb') as f:
ac_bytes = f.read()
ac_parsed = cms.AttributeCertificateV2.load(ac_bytes)
self.assertEqual(ac_bytes, ac_parsed.dump(force=True))

ac_info = ac_parsed['ac_info']
self.assertIsInstance(ac_info['issuer'].chosen, cms.V2Form)
self.assertEqual(1, len(ac_info['issuer'].chosen['issuer_name']))

def test_create_role_syntax(self):
rs = cms.RoleSyntax({'role_name': {'rfc822_name': 'test@example.com'}})
self.assertEqual(
Expand Down

0 comments on commit 6250ee4

Please sign in to comment.