|
|
@ -1,5 +1,7 @@ |
|
|
|
#!/usr/bin/env python3 |
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
|
|
|
import cmd |
|
|
|
import hashlib |
|
|
|
import json |
|
|
|
import os |
|
|
@ -416,37 +418,47 @@ def main(): |
|
|
|
] |
|
|
|
|
|
|
|
with CAManager(MANAGER_PATH) as ca_manager: |
|
|
|
print("# LILiK CA Manager") |
|
|
|
|
|
|
|
exiting = False |
|
|
|
|
|
|
|
while not exiting: |
|
|
|
selection = input('Command> ') |
|
|
|
|
|
|
|
if selection == 'help': |
|
|
|
print("Available commands:") |
|
|
|
for entry_id, entry_name in menu_entries: |
|
|
|
print("%-13s : %s" % (entry_id, entry_name)) |
|
|
|
elif selection == 'quit': |
|
|
|
exiting = True |
|
|
|
elif selection == 'list-cas': |
|
|
|
list_cas(ca_manager) |
|
|
|
elif selection == 'show-ca': |
|
|
|
pass |
|
|
|
elif selection == 'gen-ssh-ca': |
|
|
|
ca_id = input("CA unique id> ") |
|
|
|
ca_name = input("CA human-readable name> ") |
|
|
|
ca_manager.create_ssh_ca(ca_id, ca_name) |
|
|
|
elif selection == 'gen-ssl-ca': |
|
|
|
ca_id = input("CA unique id> ") |
|
|
|
ca_name = input("CA human-readable name> ") |
|
|
|
ca_manager.create_ssl_ca(ca_id, ca_name) |
|
|
|
elif selection == 'sign-request': |
|
|
|
sign_request(ca_manager) |
|
|
|
else: |
|
|
|
print("Unrecognized command. Type 'help' to show available " |
|
|
|
"commands.") |
|
|
|
|
|
|
|
class CAManagerShell(cmd.Cmd): |
|
|
|
intro= "# LILiK CA Manager" |
|
|
|
prompt= "(CA Manager)> " |
|
|
|
|
|
|
|
def __init__(self, path): |
|
|
|
self.ca_manager= CAManager(path) |
|
|
|
init_manager([ |
|
|
|
path, |
|
|
|
REQUESTS_PATH, |
|
|
|
OUTPUT_PATH, |
|
|
|
RESULTS_PATH, |
|
|
|
]) |
|
|
|
|
|
|
|
def do_ls(self): |
|
|
|
'List the available certification authorities: LS' |
|
|
|
list_cas(ca_manager) |
|
|
|
|
|
|
|
def do_show_ca(self): |
|
|
|
'Show certification authority information: SHOW_CA example' |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
def do_gen_ssh_ca(self): |
|
|
|
'Generate a SSH certification authority: GEN_SSH_CA' |
|
|
|
ca_id = input("CA unique id> ") |
|
|
|
ca_name = input("CA human-readable name> ") |
|
|
|
ca_manager.create_ssh_ca(ca_id, ca_name) |
|
|
|
|
|
|
|
def do_gen_ssl_ca(self): |
|
|
|
'Generate a SSL certification authority: GEN_SSL_CA' |
|
|
|
ca_id = input("CA unique id> ") |
|
|
|
ca_name = input("CA human-readable name> ") |
|
|
|
ca_manager.create_ssl_ca(ca_id, ca_name) |
|
|
|
|
|
|
|
def do_sign_request(self): |
|
|
|
'Sign a certificate from a request' |
|
|
|
sign_request(ca_manager) |
|
|
|
|
|
|
|
def do_quit(self): |
|
|
|
'Quit this shell' |
|
|
|
return True |
|
|
|
|
|
|
|
def list_cas(ca_manager): |
|
|
|
for ca_id, ca_name, ca_type in ca_manager.get_cas_list(): |
|
|
|