-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,9 @@ | |
.. moduleauthor:: Lex van Roon <[email protected]> | ||
""" | ||
|
||
import hashlib | ||
import os | ||
import random | ||
import shlex | ||
import subprocess | ||
import time | ||
|
@@ -157,3 +159,18 @@ def gen_enddate(days): | |
days_sec = days * (60*60*24) | ||
future_date = time.localtime(time.time() + days_sec) | ||
return time.strftime('%Y%m%d%H%M%SZ', future_date) | ||
|
||
|
||
def gentoken(): | ||
"""Utility function which generates a token based on a sha256 hash of | ||
a random value. | ||
>>> gentoken() | ||
'3b2b469df99db2e207cd6232124816caaee8e28401e495627e8209f08426f8d2' | ||
:returns: Random token | ||
:rtype: str | ||
""" | ||
sha = hashlib.sha256() | ||
sha.update(str(random.random()).encode('utf-8')) | ||
return sha.hexdigest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
# This file contains the configuration for a certificate client | ||
|
||
api: | ||
url: http://${server_host}:${server_port} | ||
token: ${client_token} | ||
|
||
certs: | ||
bits: ${crypto['bits']} | ||
hash: ${crypto['hash']} | ||
country: ${ca['country']} | ||
province: ${ca['province']} | ||
city: ${ca['city']} | ||
organization: ${ca['organization']} | ||
unit: ${ca['unit']} |