• 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 policies and requireExplicitPolicy."""
6
7import sys
8sys.path += ['../..']
9
10import gencerts
11
12# Self-signed root certificate.
13root = gencerts.create_self_signed_root_certificate('Root')
14
15# Intermediate certificate.
16intermediate = gencerts.create_intermediate_certificate('Intermediate', root)
17intermediate.get_extensions().set_property('certificatePolicies',
18                                           'critical,1.2.3.4')
19intermediate.get_extensions().set_property('policyConstraints',
20                                           'critical,requireExplicitPolicy:0')
21
22# Target certificate.
23target = gencerts.create_end_entity_certificate('Target', intermediate)
24target.get_extensions().set_property('certificatePolicies', 'critical,1.2.3.4')
25
26chain = [target, intermediate, root]
27gencerts.write_chain(__doc__, chain, 'chain.pem')
28