openvpn: When user certificate is empty, regenerate it

Signed-off-by: Hemanth Kumar Veeranki <hemanthveeranki@gmail.com>
This commit is contained in:
Hemanth Kumar Veeranki 2017-03-24 18:23:52 +05:30 committed by Sunil Mohan Adapa
parent 4a3cf220c8
commit fcd2499092
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -164,7 +164,7 @@ def subcommand_get_profile(arguments):
user_certificate = USER_CERTIFICATE_PATH.format(username=username)
user_key = USER_KEY_PATH.format(username=username)
if not os.path.isfile(user_certificate) or not os.path.isfile(user_key):
if not _is_non_empty_file(user_certificate) or not os.path.isfile(user_key):
subprocess.check_call(['/usr/share/easy-rsa/pkitool', username],
**COMMON_ARGS)
@ -185,6 +185,11 @@ def _read_file(filename):
return ''.join(file_handle.readlines())
def _is_non_empty_file(filepath):
return os.path.isfile(filepath) and os.path.getsize(filepath) > 0
pass
def main():
"""Parse arguments and perform all duties."""
arguments = parse_arguments()