mirror of
https://github.com/ansible-collections/community.crypto.git
synced 2026-05-06 13:22:58 +00:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user