|
2 | 2 | from __future__ import unicode_literals, division, absolute_import, print_function
|
3 | 3 |
|
4 | 4 | import socket
|
| 5 | +from dataclasses import dataclass, field |
5 | 6 | from datetime import datetime, timedelta
|
6 | 7 | import binascii
|
7 | 8 |
|
|
13 | 14 | from ._errors import pretty_message
|
14 | 15 | from ._types import type_name, byte_cls, str_cls
|
15 | 16 | from .errors import SoftFailError
|
| 17 | +from .name_trees import default_permitted_subtrees, PKIXSubtrees, \ |
| 18 | + default_excluded_subtrees |
16 | 19 | from .path import ValidationPath
|
17 | 20 | from .registry import CertificateRegistry
|
18 | 21 |
|
@@ -611,3 +614,79 @@ def check_crl_issuer(self, certificate_list):
|
611 | 614 | """
|
612 | 615 |
|
613 | 616 | return self._crl_issuer_map.get(certificate_list.signature)
|
| 617 | + |
| 618 | + |
| 619 | +@dataclass(frozen=True) |
| 620 | +class PKIXValidationParams: |
| 621 | + user_initial_policy_set: frozenset = frozenset(['any_policy']) |
| 622 | + """ |
| 623 | + Set of policies that the user is willing to accept. By default, any policy |
| 624 | + is acceptable. |
| 625 | + |
| 626 | + When setting this parameter to a non-default value, you probably want to |
| 627 | + set :attr:`initial_explicit_policy` as well. |
| 628 | + |
| 629 | + .. note:: |
| 630 | + These are specified in the policy domain of the trust root(s), and |
| 631 | + subject to policy mapping by intermediate certificate authorities. |
| 632 | + """ |
| 633 | + |
| 634 | + initial_policy_mapping_inhibit: bool = False |
| 635 | + """ |
| 636 | + Flag indicating whether policy mapping is forbidden along the entire |
| 637 | + certification chains. By default, policy mapping is permitted. |
| 638 | + |
| 639 | + .. note:: |
| 640 | + Policy constraints on intermediate certificates may force policy mapping |
| 641 | + to be inhibited from some point onwards. |
| 642 | + """ |
| 643 | + |
| 644 | + initial_explicit_policy: bool = False |
| 645 | + """ |
| 646 | + Flag indicating whether path validation must terminate with at least one |
| 647 | + permissible policy; see :attr:`user_initial_policy_set`. |
| 648 | + By default, no such requirement is imposed. |
| 649 | + |
| 650 | + .. note:: |
| 651 | + If :attr:`user_initial_policy_set` is set to its default value of |
| 652 | + ``{'any_policy'}``, the effect is that the path validation must accept |
| 653 | + at least one policy, without specifying which. |
| 654 | + |
| 655 | + .. warning:: |
| 656 | + Due to widespread mis-specification of policy extensions in the wild, |
| 657 | + many real-world certification chains terminate with an empty set |
| 658 | + (or rather, tree) of valid policies. Therefore, this flag is set to |
| 659 | + ``False`` by default. |
| 660 | + """ |
| 661 | + |
| 662 | + initial_any_policy_inhibit: bool = False |
| 663 | + """ |
| 664 | + Flag indicating whether ``anyPolicy`` should be left unprocessed when it |
| 665 | + appears in a certificate. By default, ``anyPolicy`` is always processed |
| 666 | + when it appears. |
| 667 | + """ |
| 668 | + |
| 669 | + initial_permitted_subtrees: PKIXSubtrees = \ |
| 670 | + field(default_factory=default_permitted_subtrees) |
| 671 | + """ |
| 672 | + Set of permitted subtrees for each name type, indicating restrictions |
| 673 | + to impose on subject names (and alternative names) in the certification |
| 674 | + path. |
| 675 | + |
| 676 | + By default, all names are permitted. |
| 677 | + This behaviour can be modified by name constraints on intermediate CA |
| 678 | + certificates. |
| 679 | + """ |
| 680 | + |
| 681 | + initial_excluded_subtrees: PKIXSubtrees = field( |
| 682 | + default_factory=default_excluded_subtrees |
| 683 | + ) |
| 684 | + """ |
| 685 | + Set of excluded subtrees for each name type, indicating restrictions |
| 686 | + to impose on subject names (and alternative names) in the certification |
| 687 | + path. |
| 688 | +
|
| 689 | + By default, no names are excluded. |
| 690 | + This behaviour can be modified by name constraints on intermediate CA |
| 691 | + certificates. |
| 692 | + """ |
0 commit comments