mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
Secure letsencrypt account_key_content better (#34979)
* Ensure temp account key file cleanup even when module fails. * Adding warning to documentation on pitfalls of using account_key_content.
This commit is contained in:
parent
f8d2f0ac44
commit
1d26686b09
1 changed files with 6 additions and 4 deletions
|
@ -55,6 +55,11 @@ options:
|
||||||
- "Content of the Let's Encrypt account RSA or Elliptic Curve key."
|
- "Content of the Let's Encrypt account RSA or Elliptic Curve key."
|
||||||
- "Mutually exclusive with C(account_key_src)."
|
- "Mutually exclusive with C(account_key_src)."
|
||||||
- "Required if C(account_key_src) is not used."
|
- "Required if C(account_key_src) is not used."
|
||||||
|
- "Warning: the content will be written into a temporary file, which will
|
||||||
|
be deleted by Ansible when the module completes. Since this is an
|
||||||
|
important private key — it can be used to change the account key,
|
||||||
|
or to revoke your certificates without knowing their private keys
|
||||||
|
—, this might not be acceptable."
|
||||||
version_added: "2.5"
|
version_added: "2.5"
|
||||||
account_email:
|
account_email:
|
||||||
description:
|
description:
|
||||||
|
@ -367,6 +372,7 @@ class ACMEAccount(object):
|
||||||
# Create a key file from content, key (path) and key content are mutually exclusive
|
# Create a key file from content, key (path) and key content are mutually exclusive
|
||||||
if self.key_content is not None:
|
if self.key_content is not None:
|
||||||
_, tmpsrc = tempfile.mkstemp()
|
_, tmpsrc = tempfile.mkstemp()
|
||||||
|
module.add_cleanup_file(tmpsrc) # Ansible will delete the file on exit
|
||||||
f = open(tmpsrc, 'wb')
|
f = open(tmpsrc, 'wb')
|
||||||
try:
|
try:
|
||||||
f.write(self.key_content)
|
f.write(self.key_content)
|
||||||
|
@ -915,10 +921,6 @@ class ACMEClient(object):
|
||||||
self.cert_days = get_cert_days(self.module, self.dest)
|
self.cert_days = get_cert_days(self.module, self.dest)
|
||||||
self.changed = True
|
self.changed = True
|
||||||
|
|
||||||
# Clean up temporary account key file
|
|
||||||
if self.module.params['account_key_content'] is not None:
|
|
||||||
os.remove(self.account.key)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue