-
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix x509.Name.build() to properly handle all fields
Previously it did not properly handle the following fields: - unique_identifier - tpm_manufacturer - tpm_model - tpm_version - platform_manufacturer - platform_model - platform_version Fixes #260
- Loading branch information
Showing
2 changed files
with
35 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -466,6 +466,25 @@ def test_build_name_printable(self): | |
self.assertIsInstance(printable_name.chosen[2][0]['value'].chosen, core.PrintableString) | ||
self.assertEqual('common_name', printable_name.chosen[2][0]['type'].native) | ||
|
||
def test_build_name_type_by_oid(self): | ||
complex_name = x509.Name.build( | ||
{ | ||
'country_name': 'US', | ||
'tpm_manufacturer': 'Acme Co', | ||
'unique_identifier': b'\x04\x10\x03\x09', | ||
'email_address': '[email protected]' | ||
} | ||
) | ||
self.assertEqual("country_name", complex_name.chosen[0][0]['type'].native) | ||
self.assertIsInstance(complex_name.chosen[0][0]['value'], x509.DirectoryString) | ||
self.assertIsInstance(complex_name.chosen[0][0]['value'].chosen, core.PrintableString) | ||
self.assertEqual("email_address", complex_name.chosen[1][0]['type'].native) | ||
self.assertIsInstance(complex_name.chosen[1][0]['value'], x509.EmailAddress) | ||
self.assertEqual("tpm_manufacturer", complex_name.chosen[2][0]['type'].native) | ||
self.assertIsInstance(complex_name.chosen[2][0]['value'], core.UTF8String) | ||
self.assertEqual("unique_identifier", complex_name.chosen[3][0]['type'].native) | ||
self.assertIsInstance(complex_name.chosen[3][0]['value'], core.OctetBitString) | ||
|
||
def test_v1_cert(self): | ||
cert = self._load_cert('chromium/ndn.ca.crt') | ||
tbs_cert = cert['tbs_certificate'] | ||
|