[IMP] Check directory before create root ca
This commit is contained in:
@@ -75,31 +75,36 @@ class TisPKI:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def check_directories(root_path):
|
def check_directories(path):
|
||||||
print('Check directories')
|
print('Check directories')
|
||||||
|
|
||||||
directories_list = ['certs','config','crl','newcerts','private','csr','crl','p12']
|
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')
|
print(f'Create { root_path } directory')
|
||||||
os.makedirs(root_path)
|
os.makedirs(path)
|
||||||
|
|
||||||
for directory in directories_list:
|
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):
|
if not os.path.isdir(directory_path):
|
||||||
print(f'Create { directory_path } directory')
|
print(f'Create { directory_path } directory')
|
||||||
os.makedirs(directory_path)
|
os.makedirs(directory_path)
|
||||||
|
|
||||||
if not os.path.isfile(os.path.join(root_path,'index.txt')):
|
if not os.path.isfile(os.path.join(path,'index.txt')):
|
||||||
with open(os.path.join(root_path,'index.txt'),'w') as file:
|
with open(os.path.join(path,'index.txt'),'w') as file:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def create_openssl_config():
|
def create_openssl_config():
|
||||||
print('Check Root CA 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):
|
if not os.path.isfile(root_ca_config):
|
||||||
print('Root CA OpenSSL configfile not exist. Creating...')
|
print('Root CA OpenSSL configfile not exist. Creating...')
|
||||||
|
|||||||
Reference in New Issue
Block a user