• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright 2016 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 root has a smaller validity range than the other
7certificates, making it easy to violate just its validity.
8
9  Root:          2015/03/01 -> 2015/09/01
10  Intermediate:  2015/01/01 -> 2016/01/01
11  Target:        2015/01/01 -> 2016/01/01
12"""
13
14
15import sys
16sys.path += ['../..']
17
18import gencerts
19
20# Self-signed root certificate.
21root = gencerts.create_self_signed_root_certificate('Root')
22root.set_validity_range(gencerts.MARCH_1_2015_UTC,
23                        gencerts.SEPTEMBER_1_2015_UTC)
24
25# Intermediate certificate.
26intermediate = gencerts.create_intermediate_certificate('Intermediate', root)
27intermediate.set_validity_range(gencerts.JANUARY_1_2015_UTC,
28                                gencerts.JANUARY_1_2016_UTC)
29
30# Target certificate.
31target = gencerts.create_end_entity_certificate('Target', intermediate)
32target.set_validity_range(gencerts.JANUARY_1_2015_UTC,
33                          gencerts.JANUARY_1_2016_UTC)
34
35chain = [target, intermediate, root]
36gencerts.write_chain(__doc__, chain, 'chain.pem')
37