[IMP] Add verbose messages
This commit is contained in:
@@ -115,7 +115,7 @@ def check_directories(path):
|
||||
pass
|
||||
|
||||
|
||||
def create_openssl_config():
|
||||
def create_openssl_config(verbose=False):
|
||||
print('Check Root CA OpenSSL Config')
|
||||
|
||||
if config.get('general','pki_dir'):
|
||||
@@ -153,12 +153,13 @@ def create_openssl_config():
|
||||
print('Root CA OpenSSL config already exist. Skip.')
|
||||
|
||||
# Generate privkey and cert for Root CA
|
||||
if not os.path.isfile(TisPKI.root_ca_keyfile()) and not os.path.isfile(TisPKI.root_ca_certfile()):
|
||||
if not os.path.isfile(TisPKI.root_ca_keyfile()) or not os.path.isfile(TisPKI.root_ca_certfile()):
|
||||
print('Generate Root CA private key')
|
||||
gen_root_ca = subprocess.run(f'/usr/bin/openssl req -x509 -new -sha512 -config {root_ca_config} -days 3650 -extensions v3_ca -keyout {TisPKI.root_ca_keyfile()} -out {TisPKI.root_ca_certfile()}', shell=True, check=True, executable='/bin/bash')
|
||||
gen_root_ca = subprocess.run(f'/usr/bin/openssl req -x509 -new -sha512 -config {root_ca_config} -days 3650 -extensions v3_ca -keyout {TisPKI.root_ca_keyfile()} -out {TisPKI.root_ca_certfile()}', shell=True, check=False, executable='/bin/bash')
|
||||
|
||||
if gen_root_ca.returncode == 0:
|
||||
subprocess.run(f'openssl x509 -in {TisPKI.root_ca_certfile()} -text', shell=True, check=True, executable='/bin/bash')
|
||||
if verbose:
|
||||
subprocess.run(f'openssl x509 -in {TisPKI.root_ca_certfile()} -text', shell=True, check=True, executable='/bin/bash')
|
||||
Printing.information(f'Root CA Certfile is stored in {TisPKI.root_ca_certfile()}')
|
||||
input("Press Enter to continue...")
|
||||
else:
|
||||
|
||||
+2
-1
@@ -19,11 +19,12 @@ def main():
|
||||
parser.add_option('--initialize', dest="initialize", action="store_true", help="Create PKI")
|
||||
parser.add_option('--create-intermediate', dest="create_intermediate", action="store_true", help="Create an intermediate CA")
|
||||
parser.add_option('--create-dc-cert', dest="create_dc_cert", action="store_true", help="Create a certificat for a Domain Controler")
|
||||
parser.add_option('-v', '--verbose', dest="verbose", action="store_true", help="Print all command")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if options.initialize:
|
||||
create_openssl_config()
|
||||
create_openssl_config(verbose=options.verbose)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user