Skip to content

Commit

Permalink
Merge pull request #5 from MatthiasValvekens/bugfix/reinstate-asn1cry…
Browse files Browse the repository at this point in the history
…pto-registration

Reinstate asn1crypto registration of AA types
  • Loading branch information
MatthiasValvekens authored Jul 15, 2022
2 parents 247ade7 + 4121bbb commit bb5a0ae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
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

0 comments on commit bb5a0ae

Please sign in to comment.