• 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 where the leaf has a basic constraints extension with
6CA=true"""
7
8import sys
9sys.path += ['../..']
10
11import gencerts
12
13# Self-signed root certificate.
14root = gencerts.create_self_signed_root_certificate('Root')
15
16# Intermediate certificate.
17intermediate = gencerts.create_intermediate_certificate('Intermediate', root)
18
19# Target certificate (end entity, but has pathlen set).
20target = gencerts.create_end_entity_certificate('Target', intermediate)
21target.get_extensions().set_property('basicConstraints', 'critical,CA:true')
22
23chain = [target, intermediate, root]
24gencerts.write_chain(__doc__, chain, 'chain.pem')
25gencerts.write_chain(__doc__, [target], 'target_only.pem')
26