community.crypto.openssl_signature (2.18.0) — module

Sign data with openssl

| "added in version" 1.1.0 of community.crypto"

Authors: Patrick Pichler (@aveexy), Markus Teufelberger (@MarkusTeufelberger)

Install collection

Install with ansible-galaxy collection install community.crypto:==2.18.0


Add to requirements.yml

  collections:
    - name: community.crypto
      version: 2.18.0

Description

This module allows one to sign data using a private key.

The module uses the cryptography Python library.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Sign example file
  community.crypto.openssl_signature:
    privatekey_path: private.key
    path: /tmp/example_file
  register: sig
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Verify signature of example file
  community.crypto.openssl_signature_info:
    certificate_path: cert.pem
    path: /tmp/example_file
    signature: "{{ sig.signature }}"
  register: verify
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Make sure the signature is valid
  ansible.builtin.assert:
    that:
      - verify.valid

Inputs

    
path:
    description:
    - The file to sign.
    - This file will only be read and not modified.
    required: true
    type: path

privatekey_path:
    description:
    - The path to the private key to use when signing.
    - Either O(privatekey_path) or O(privatekey_content) must be specified, but not both.
    type: path

privatekey_content:
    description:
    - The content of the private key to use when signing the certificate signing request.
    - Either O(privatekey_path) or O(privatekey_content) must be specified, but not both.
    type: str

privatekey_passphrase:
    description:
    - The passphrase for the private key.
    - This is required if the private key is password protected.
    type: str

select_crypto_backend:
    choices:
    - auto
    - cryptography
    default: auto
    description:
    - Determines which crypto backend to use.
    - The default choice is V(auto), which tries to use C(cryptography) if available.
    - If set to V(cryptography), will try to use the L(cryptography,https://cryptography.io/)
      library.
    type: str

Outputs

signature:
  description: Base64 encoded signature.
  returned: success
  type: str

See also