Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinstate asn1crypto registration of AA types #5

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions certomancer/_asn1_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,25 @@ class AAControls(core.Sequence):
('excluded_attrs', AttrSpec, {'optional': True, 'implicit': 1}),
('permit_unspecified', core.Boolean, {'default': True})
]


def register_extensions():
# patch in attribute certificate extensions
# Note: we only make these patches so that we can reliably produce the
# relevant values, and don't insist on supplying Certomancer's internal
# definitions at the Python level if some other library already supplied
# them
ext_map = x509.ExtensionId._map
ext_specs = x509.Extension._oid_specs
if '2.5.29.55' not in ext_map:
ext_map['2.5.29.55'] = 'target_information'
ext_specs['target_information'] = SequenceOfTargets
if '2.5.29.56' not in ext_map:
ext_map['2.5.29.56'] = 'no_rev_avail'
ext_specs['no_rev_avail'] = core.Null
if '1.3.6.1.5.5.7.1.6' not in ext_map:
ext_map['1.3.6.1.5.5.7.1.6'] = 'aa_controls'
ext_specs['aa_controls'] = AAControls


register_extensions()
5 changes: 5 additions & 0 deletions certomancer/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@
from .registry import CertomancerConfig, CertLabel, ServiceLabel
from .services import CertomancerServiceError
from .version import __version__
from ._asn1_types import register_extensions

DEFAULT_CONFIG_FILE = 'certomancer.yml'
logger = logging.getLogger(__name__)

# This is a no-op since the registration happens automatically,
# but explicit is better than implicit
register_extensions()


def _log_config():
_logger = logging.getLogger('certomancer')
Expand Down