Debian Codegraph @

README.md

raw
1 # Certipy
2
3 A simple python tool for creating certificate authorities and certificates on
4 the fly.
5
6 ## Introduction
7
8 Certipy was made to simplify the certificate creation process. To that end,
9 Certipy exposes methods for creating and managing certificate authorities,
10 certificates, signing and building trust bundles. Behind the scenes Certipy:
11
12 * Manages records of all certificates it creates
13 * External certs can be imported and managed by Certipy
14 * Maintains signing hierarchy
15 * Persists certificates to files with appropriate permissions
16
17 ## Usage
18
19 ### Command line
20
21 Creating a certificate authority:
22
23 Certipy defaults to writing certs and certipy.json into a folder called `out`
24 in your current directory.
25
26 ```
27 $ certipy foo
28 FILES {'ca': '', 'cert': 'out/foo/foo.crt', 'key': 'out/foo/foo.key'}
29 IS_CA True
30 SERIAL 0
31 SIGNEES None
32 PARENT_CA
33 ```
34
35 Creating and signing a key-cert pair:
36
37 ```
38 $ certipy bar --ca-name foo
39 FILES {'ca': 'out/foo/foo.crt', 'key': 'out/bar/bar.key', 'cert': 'out/bar/bar.crt'}
40 IS_CA False
41 SERIAL 0
42 SIGNEES None
43 PARENT_CA foo
44 ```
45
46 Removal:
47
48 ```
49 certipy --rm bar
50 Deleted:
51 FILES {'ca': 'out/foo/foo.crt', 'key': 'out/bar/bar.key', 'cert': 'out/bar/bar.crt'}
52 IS_CA False
53 SERIAL 0
54 SIGNEES None
55 PARENT_CA foo
56 ```
57
58 ### Code
59
60 Creating a certificate authority:
61
62 ```
63 from certipy import Certipy
64
65 certipy = Certipy(store_dir='/tmp')
66 certipy.create_ca('foo')
67 record = certipy.store.get_record('foo')
68 ```
69
70 Creating and signing a key-cert pair:
71
72 ```
73 certipy.create_signed_pair('bar', 'foo')
74 record = certipy.store.get_record('bar')
75 ```
76
77 Creating trust:
78
79 ```
80 certipy.create_ca_bundle('ca-bundle.crt')
81
82 # or to trust specific certs only:
83 certipy.create_ca_bundle_for_names('ca-bundle.crt', ['bar'])
84 ```
85
86 Removal:
87
88 ```
89 record = certipy.remove_files('bar')
90 ```
91
92 Records are dicts with the following structure:
93
94 ```
95 {
96 'serial': 0,
97 'is_ca': true,
98 'parent_ca': 'ca_name',
99 'signees': {
100 'signee_name': 1
101 },
102 'files': {
103 'key': 'path/to/key.key',
104 'cert': 'path/to/cert.crt',
105 'ca': 'path/to/ca.crt',
106 }
107 }
108 ```
109
110 The `signees` will be empty for non-CA certificates. The `signees` field
111 is stored as a python `Counter`. These relationships are used to build trust
112 bundles.
113
114 Information in Certipy is generally passed around as records which point to
115 actual files. For most `_record` methods, there are generally equivalent
116 `_file` methods that operate on files themselves. The former will only affect
117 records in Certipy's store and the latter will affect both (something happens
118 to the file, the record for it should change, too).
119
120 ### Release
121
122 Certipy is released under BSD license. For more details see the LICENSE file.
123
124 LLNL-CODE-754897