• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# Copyright 2023 The Chromium Authors
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5"""Certificate chain with inhibitAnyPolicy=1 on the root, and an intermediate
6that uses anyPolicy. Should succeed since anyPolicy is still allowed for
7intermediate."""
8
9import sys
10sys.path += ['../..']
11
12import gencerts
13
14# Self-signed root certificate.
15root = gencerts.create_self_signed_root_certificate('Root')
16root.get_extensions().set_property('inhibitAnyPolicy', 'critical,1')
17
18# Intermediate certificate.
19intermediate = gencerts.create_intermediate_certificate('Intermediate', root)
20intermediate.get_extensions().set_property('policyConstraints',
21                                           'critical,requireExplicitPolicy:0')
22
23intermediate.get_extensions().set_property('certificatePolicies',
24                                           'critical,anyPolicy')
25
26# Target certificate.
27target = gencerts.create_end_entity_certificate('Target', intermediate)
28target.get_extensions().set_property('certificatePolicies', 'critical,1.2.3.5')
29
30chain = [target, intermediate, root]
31gencerts.write_chain(__doc__, chain, 'chain.pem')
32