• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright 2015 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
6"""Certificate chain where the intermediate sets pathlen=0, and is followed by
7a self-issued intermediate."""
8
9import sys
10sys.path += ['../..']
11
12import gencerts
13
14# Self-signed root certificate.
15root = gencerts.create_self_signed_root_certificate('Root')
16
17# Intermediate with pathlen 0
18intermediate1 = gencerts.create_intermediate_certificate('Intermediate', root)
19intermediate1.get_extensions().set_property('basicConstraints',
20                                            'critical,CA:true,pathlen:0')
21
22# Another intermediate (with the same pathlen restriction).
23# Note that this is self-issued but NOT self-signed.
24intermediate2 = gencerts.create_intermediate_certificate('Intermediate',
25                                                         intermediate1)
26intermediate2.get_extensions().set_property('basicConstraints',
27                                            'critical,CA:true,pathlen:0')
28
29# Target certificate.
30target = gencerts.create_end_entity_certificate('Target', intermediate2)
31
32chain = [target, intermediate2, intermediate1, root]
33gencerts.write_chain(__doc__, chain, 'chain.pem')
34