Add openssl_privatekey_convert module (#362)

* Add openssl_privatekey_convert module.

* Extend tests and fix bugs.

* Fix wrong required.

* Fix condition.

* Fix bad tests.

* Fix documentation for format.

* Fix copyright lines.
This commit is contained in:
Felix Fontein
2022-01-10 21:01:52 +01:00
committed by GitHub
parent 62272296da
commit bd2bd79497
9 changed files with 972 additions and 16 deletions

View File

@@ -24,6 +24,19 @@ import os
import tempfile
def load_file(path, module=None):
'''
Load the file as a bytes string.
'''
try:
with open(path, 'rb') as f:
return f.read()
except Exception as exc:
if module is None:
raise
module.fail_json('Error while loading {0} - {1}'.format(path, str(exc)))
def load_file_if_exists(path, module=None, ignore_errors=False):
'''
Load the file as a bytes string. If the file does not exist, ``None`` is returned.