[IMP] Check directory before create root ca

This commit is contained in:
2024-05-07 16:15:14 +02:00
parent 06cc27fbd6
commit 27b3e7e84d
+12 -7
View File
@@ -75,31 +75,36 @@ class TisPKI:
def check_directories(root_path):
def check_directories(path):
print('Check directories')
directories_list = ['certs','config','crl','newcerts','private','csr','crl','p12']
if not os.path.isdir(root_path):
if not os.path.isdir(path):
print(f'Create { root_path } directory')
os.makedirs(root_path)
os.makedirs(path)
for directory in directories_list:
directory_path = os.path.join(root_path,directory)
directory_path = os.path.join(path,directory)
if not os.path.isdir(directory_path):
print(f'Create { directory_path } directory')
os.makedirs(directory_path)
if not os.path.isfile(os.path.join(root_path,'index.txt')):
with open(os.path.join(root_path,'index.txt'),'w') as file:
if not os.path.isfile(os.path.join(path,'index.txt')):
with open(os.path.join(path,'index.txt'),'w') as file:
pass
def create_openssl_config():
print('Check Root CA OpenSSL Config')
root_ca_config = os.path.join(TisPKI.pki_dir(),'config','openssl_root_ca.ini')
if config.get('general','pki_dir'):
check_directories(path=config.get('general','pki_dir'))
else:
print('No pki_dir set in samba-pki-tools.ini')
sys.exit(1)
root_ca_config = os.path.join(TisPKI.pki_dir(),'config','openssl_root_ca.ini')
if not os.path.isfile(root_ca_config):
print('Root CA OpenSSL configfile not exist. Creating...')