Skip to content

Commit 8b91083

Browse files
author
Keyfactor
committed
Update generated README
1 parent 45d5021 commit 8b91083

File tree

1 file changed

+377
-0
lines changed

1 file changed

+377
-0
lines changed

README.md

Lines changed: 377 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,377 @@
1+
# Keyfactor Command Utility (kfutil)
2+
3+
`kfutil` is a go-lang CLI wrapper for Keyfactor Command API. It also includes other utility/helper functions around automating common Keyfactor Command operations.
4+
5+
#### Integration status: Pilot - Ready for use in test environments. Not for use in production.
6+
7+
## About the Keyfactor API Client
8+
9+
This API client allows for programmatic management of Keyfactor resources.
10+
11+
12+
13+
## Support for Keyfactor Command Utility (kfutil)
14+
15+
Keyfactor Command Utility (kfutil) is open source and there is **no SLA** for this tool/library/client. Keyfactor will address issues as resources become available. Keyfactor customers may request escalation by opening up a support ticket through their Keyfactor representative.
16+
17+
###### To report a problem or suggest a new feature, use the **[Issues](../../issues)** tab. If you want to contribute actual bug fixes or proposed enhancements, use the **[Pull requests](../../pulls)** tab.
18+
___
19+
20+
21+
22+
23+
## Quickstart
24+
25+
```bash
26+
make install
27+
kfutil --help
28+
````
29+
30+
### Environmental Variables
31+
32+
All the variables listed below need to be set in your environment. The `kfutil` command will look for these variables
33+
and use them if they are set. If they are not set, the utility will fail to connect to Keyfactor.
34+
35+
Linux/MacOS:
36+
```bash
37+
export KEYFACTOR_HOSTNAME=<mykeyfactorhost.mydomain.com>
38+
export KEYFACTOR_USERNAME=<myusername> # Do not include domain
39+
export KEYFACTOR_PASSWORD=<mypassword>
40+
export KEYFACTOR_DOMAIN=<mykeyfactordomain>
41+
```
42+
43+
Windows Powershell
44+
```powershell
45+
$env:KEYFACTOR_HOSTNAME="<mykeyfactorhost.mydomain.com>"
46+
$env:KEYFACTOR_USERNAME="<myusername>" # Do not include domain
47+
$env:KEYFACTOR_PASSWORD="<mypassword>"
48+
$env:KEYFACTOR_DOMAIN="<mykeyfactordomain>"
49+
```
50+
51+
## Commands
52+
53+
### Login
54+
For full documentation on the `login` command, see the [login](docs/kfutil_login.md) documentation.
55+
56+
*WARNING* - The `login` command will store your Keyfactor credentials in a file on your local machine. This file is not
57+
encrypted and is not secure. It is recommended that you use the `login` command only on your local machine and not on a
58+
shared machine. Instead of using the `login` command, you can set the environmental variables listed above.
59+
60+
```bash
61+
kfutil login
62+
```
63+
64+
### Logout
65+
For full documentation on the `logout` command, see the [logout](docs/kfutil_logout.md) documentation.
66+
67+
*WARNING* - This will delete the file containing your Keyfactor credentials at `$HOME/.keyfactor/command_config.json`.
68+
69+
```bash
70+
kfutil logout
71+
```
72+
73+
## Commands
74+
75+
### Bulk operations
76+
77+
#### Bulk create cert stores
78+
79+
For full documentation, see [stores import](docs/kfutil_stores_import.md).
80+
81+
This will attempt to process a CSV input file of certificate stores to create. The template can be generated by
82+
running: `kfutil stores import generate-template` command.
83+
84+
```bash
85+
kfutil stores import create --file <file name to import> --store-type-id <store type id> --store-type-name <store type name> --results-path <filepath for results> --dry-run <check fields only> [flags]
86+
```
87+
88+
```bash
89+
kfutil stores import --help
90+
Tool for generating import templates and importing certificate stores
91+
92+
Usage:
93+
kfutil stores import [command]
94+
95+
Available Commands:
96+
create Create certificate stores
97+
generate-template For generating a CSV template with headers for bulk store creation.
98+
99+
Flags:
100+
-h, --help help for import
101+
102+
Use "kfutil stores import [command] --help" for more information about a command.
103+
```
104+
105+
#### Bulk create cert store types
106+
107+
For full documentation, see [store-types](docs/kfutil_store-types.md).
108+
109+
This will attempt to process a CSV input file of certificate store types to create. The template can be generated by
110+
running: `kfutil generate-template --type bulk-certstore-types` command.
111+
112+
```bash
113+
kfutil store-types create --name $STORE_TYPE_NAME
114+
```
115+
116+
```bash
117+
kfutil store-types --help
118+
A collections of APIs and utilities for interacting with Keyfactor Command certificate store types.
119+
120+
Usage:
121+
kfutil store-types [command]
122+
123+
Available Commands:
124+
create Create a new certificate store type in Keyfactor Command.
125+
delete Delete a specific store type by ID.
126+
get Get a specific store type by either name or ID.
127+
list List certificate store types.
128+
templates-fetch Fetches store type templates from Keyfactor's Github.
129+
update Update a certificate store type in Keyfactor.
130+
131+
Flags:
132+
-h, --help help for store-types
133+
134+
Use "kfutil store-types [command] --help" for more information about a command.
135+
```
136+
137+
### Root of Trust
138+
139+
For full documentation, see [stores rot](docs/kfutil_stores_rot.md).
140+
141+
The root of trust (rot) utility is a tool that allows you to bulk manage Keyfactor certificate stores and ensure that a
142+
set of defined certificates are present in each store that meets a certain set of criteria or no criteria at all.
143+
144+
### Root of Trust Quickstart
145+
146+
```bash
147+
echo "Generating cert template file certs_template.csv"
148+
kfutil stores rot generate-template-rot --type certs
149+
# edit the certs_template.csv file
150+
echo "Generating stores template file stores_template.csv"
151+
kfutil stores rot generate-template-rot --type stores
152+
# edit the stores_template.csv file
153+
kfutil stores rot audit --add-certs certs_template.csv --stores stores_template.csv #This will audit the stores and generate a report file
154+
# review/edit the report file generated `rot_audit.csv`
155+
kfutil stores rot reconcile --import-csv
156+
# Alternatively this can be done in one step
157+
kfutil stores rot reconcile --add-certs certs_template.csv --stores stores_template.csv
158+
```
159+
160+
#### Generate Certificate List Template
161+
162+
For full documentation, see [stores rot generate template](docs/kfutil_stores_rot_generate-template.md).
163+
164+
This will write the file `certs_template.csv` to the current directory.
165+
166+
```bash
167+
kfutil stores generate-template-rot --type certs
168+
```
169+
170+
#### Generate Certificate Store List Template
171+
172+
For full documentation, see [stores rot generate template](docs/kfutil_stores_rot_generate-template.md).
173+
174+
This will write the file `stores_template.csv` to the current directory. For full documentation
175+
176+
```bash
177+
kfutil stores generate-template-rot --type stores
178+
```
179+
180+
#### Run Root of Trust Audit
181+
182+
For full documentation, see [stores rot audit](docs/kfutil_stores_rot_audit.md).
183+
184+
Audit will take in a list of certificates and a list of certificate stores and check that the certificate store's
185+
inventory either contains the certificate or does not contain the certificate based on the `--add-certs` and
186+
`--remove-certs` flags. These flags can be used together or separately. The aforementioned flags take in a path to CSV
187+
files containing a list of certificate thumbprints. To generate a template for these files, run the following command:
188+
189+
```bash
190+
kfutil stores rot generate-template --type certs
191+
```
192+
193+
To prepopulate the template file you can provide `--cn` multiple times.
194+
195+
```bash
196+
kfutil stores rot generate-template --type certs \
197+
--cn <cert subject name> \
198+
--cn <additional cert subject name>
199+
```
200+
201+
In addition, you must provide a list of stores you wish to audit. To generate a template for this file, run the
202+
following
203+
command:
204+
205+
```bash
206+
kfutil stores rot generate-template --type stores
207+
```
208+
209+
To prepopulate the template file you can provide `--store-type` and `--container-type` multiple times.
210+
211+
```bash
212+
kfutil stores rot generate-template --type stores \
213+
--store-type <store type name> \
214+
--store-type <additional store type name> \
215+
--container-type <container type name> \
216+
--container-type <additional container type name>
217+
```
218+
219+
With all the files generated and populated, you can now run the audit command:
220+
221+
```bash
222+
kfutil stores rot audit \
223+
--stores stores_template.csv \
224+
--add-certs certs_template.csv \
225+
--remove-certs certs_template2.csv
226+
```
227+
228+
This will generate an audit file that contains the results of the audit and actions that will be taken if `reconcile` is
229+
executed. By default, the audit file will be named `rot_audit.csv` and will be written to the current directory. To
230+
output
231+
the audit file to a different location, use the `--output` flag:
232+
233+
```bash
234+
kfutil stores rot audit \
235+
--stores stores.csv \
236+
--add-certs addCerts.csv \
237+
--remove-certs removeCerts.csv \
238+
--output /path/to/output/autdit_file.csv
239+
```
240+
241+
#### Run Root of Trust Reconcile
242+
243+
For full documentation, see [stores rot](docs/kfutil_stores_rot_reconcile.md).
244+
245+
Reconcile will take in a list of certificates and a list of certificate stores and check that the certificate store's
246+
inventory either contains the certificate or does not contain the certificate based on the `--add-certs` and
247+
`--remove-certs` flags. These flags can be used together or separately. The aforementioned flags take in a path to CSV
248+
files containing a list of certificate thumbprints. To generate a template for these files, run the following command:
249+
250+
```bash
251+
kfutil stores rot generate-template --type certs
252+
```
253+
254+
To pre-populate the template file you can provide `--cn` multiple times.
255+
256+
```bash
257+
kfutil stores rot generate-template --type certs \
258+
--cn <cert subject name> \
259+
--cn <additional cert subject name>
260+
```
261+
262+
In addition, you must provide a list of stores you wish to reconcile. To generate a template for this file, run the
263+
following
264+
command:
265+
266+
```bash
267+
kfutil stores rot generate-template --type stores
268+
```
269+
270+
To pre-populate the stores template file you can provide multiple values in any combination of the following flags:
271+
272+
```bash
273+
kfutil stores rot generate-template --type stores \
274+
--store-type <store type name> \
275+
--store-type <additional store type name> \
276+
--container-type <container type name> \
277+
--container-type <additional container type name>
278+
```
279+
280+
With all the files generated and populated, you can now run the reconcile command:
281+
282+
```bash
283+
kfutil stores rot reconcile \
284+
--stores stores_template.csv \
285+
--add-certs certs_template.csv \
286+
--remove-certs certs_template2.csv
287+
```
288+
289+
This will generate an audit file that contains the results of the audit and actions will immediately execute those
290+
actions.
291+
By default, the reconcile file will be named `rot_audit.csv` and will be written to the current directory. To output
292+
the reconcile file to a different location, use the `--output` flag:
293+
294+
```bash
295+
kfutil stores rot reconcile \
296+
--stores stores.csv \
297+
--add-certs addCerts.csv \
298+
--remove-certs removeCerts.csv \
299+
--output /path/to/output/audit_file.csv
300+
```
301+
302+
Alternatively you can provide an audit CSV file as an input to the reconcile command using the `--import-csv` flag:
303+
304+
```bash
305+
kfutil stores rot reconcile \
306+
--import-csv /path/to/audit_file.csv
307+
```
308+
309+
### Certificate Store Inventory
310+
311+
For full documentation, see [stores inventory](docs/kfutil_stores_inventory.md).
312+
313+
#### Show the inventory of a certificate store
314+
315+
For full documentation, see [stores inventory show](docs/kfutil_stores_inventory_show.md).
316+
317+
```bash
318+
# Show by store ID:
319+
```bash
320+
kfutil stores inventory show --sid <store id>
321+
322+
# Nested command lookup: shows inventory of first cert store found
323+
kfutil stores inventory show \
324+
--sid $(kfutil stores list | jq -r ".[0].Id")
325+
```
326+
327+
Show by client machine name:
328+
329+
```bash
330+
kfutil stores inventory show --client <machine name>
331+
332+
# Nested command lookup: shows inventory of first cert store found
333+
kfutil stores inventory show \
334+
--client $(kfutil orchs list | jq -r ".[0].ClientMachine")
335+
```
336+
337+
#### Add certificates to certificate stores
338+
339+
For full documentation, see [stores inventory add](docs/kfutil_stores_inventory_add.md).
340+
341+
```bash
342+
# Add 2 certs to 2 certificate stores
343+
kfutil stores inventory add \
344+
--sid <store id> \
345+
--sid <additional store id> \
346+
--cn <cert subject name> \
347+
--cn <additional cert subject name>
348+
```
349+
350+
#### Remove certificates from certificate stores
351+
352+
For full documentation, see [stores inventory remove](docs/kfutil_stores_inventory_remove.md).
353+
354+
```bash
355+
# Remove 2 certs from all stores associated with a client machine
356+
kfutil stores inventory remove \
357+
--client <machine name> \
358+
--cn <cert subject name> \
359+
--cn <additional cert subject name>
360+
```
361+
362+
## Development
363+
364+
This CLI developed using [cobra](https://umarcor.github.io/cobra/)
365+
366+
### Adding a new command
367+
368+
```bash
369+
cobra-cli add <my-new-command>
370+
```
371+
372+
alternatively you can specify the parent command
373+
374+
```bash
375+
cobra-cli add <my-new-command> -p '<parent>Cmd'
376+
```
377+

0 commit comments

Comments
 (0)