diff --git a/actions/openvpn b/actions/openvpn index d62e84bf2..8a4106966 100755 --- a/actions/openvpn +++ b/actions/openvpn @@ -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()