community.crypto.openssl_publickey_info – Provide information for OpenSSL public keys

Note

This plugin is part of the community.crypto collection (version 1.9.3).

To install it use: ansible-galaxy collection install community.crypto.

To use it in a playbook, specify: community.crypto.openssl_publickey_info.

New in version 1.7.0: of community.crypto

Synopsis

  • This module allows one to query information on OpenSSL public keys.

  • It uses the pyOpenSSL or cryptography python library to interact with OpenSSL. If both the cryptography and PyOpenSSL libraries are available (and meet the minimum version requirements) cryptography will be preferred as a backend over PyOpenSSL (unless the backend is forced with select_crypto_backend). Please note that the PyOpenSSL backend was deprecated in Ansible 2.9 and will be removed in community.crypto 2.0.0.

Requirements

The below requirements are needed on the host that executes this module.

  • PyOpenSSL >= 0.15 or cryptography >= 1.2.3

Parameters

Parameter Choices/Defaults Comments
content
string
Content of the public key file.
Either path or content must be specified, but not both.
path
path
Remote absolute path where the public key file is loaded from.
select_crypto_backend
string
    Choices:
  • auto ←
  • cryptography
  • pyopenssl
Determines which crypto backend to use.
The default choice is auto, which tries to use cryptography if available, and falls back to pyopenssl.
If set to pyopenssl, will try to use the pyOpenSSL library.
If set to cryptography, will try to use the cryptography library.
Please note that the pyopenssl backend has been deprecated in Ansible 2.9, and will be removed in community.crypto 2.0.0. From that point on, only the cryptography backend will be available.

Notes

Note

  • Supports check_mode.

See Also

See also

community.crypto.openssl_publickey

The official documentation on the community.crypto.openssl_publickey module.

community.crypto.openssl_privatekey_info

The official documentation on the community.crypto.openssl_privatekey_info module.

Examples

- name: Generate an OpenSSL private key with the default values (4096 bits, RSA)
  community.crypto.openssl_privatekey:
    path: /etc/ssl/private/ansible.com.pem

- name: Create public key from private key
  community.crypto.openssl_privatekey:
    privatekey_path: /etc/ssl/private/ansible.com.pem
    path: /etc/ssl/ansible.com.pub

- name: Get information on public key
  community.crypto.openssl_publickey_info:
    path: /etc/ssl/ansible.com.pub
  register: result

- name: Dump information
  ansible.builtin.debug:
    var: result

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
fingerprints
dictionary
success
Fingerprints of public key.
For every hash algorithm available, the fingerprint is computed.

Sample:
{'sha256': 'd4:b3:aa:6d:c8:04:ce:4e:ba:f6:29:4d:92:a3:94:b0:c2:ff:bd:bf:33:63:11:43:34:0f:51:b0:95:09:2f:63', 'sha512': 'f7:07:4a:f0:b0:f0:e6:8b:95:5f:f9:e6:61:0a:32:68:f1...
public_data
dictionary
success
Public key data. Depends on key type.

 
curve
string
When type=ECC
The curve's name for ECC.

 
exponent
integer
When type=RSA
The RSA key's public exponent.

 
exponent_size
integer
When type=ECC
The maximum number of bits of a private key. This is basically the bit size of the subgroup used.

 
g
integer
When type=DSA
The g value for DSA.
This is the element spanning the subgroup of the multiplicative group of the prime field used.

 
modulus
integer
When type=RSA
The RSA key's modulus.

 
p
integer
When type=DSA
The p value for DSA.
This is the prime modulus upon which arithmetic takes place.

 
q
integer
When type=DSA
The q value for DSA.
This is a prime that divides p - 1, and at the same time the order of the subgroup of the multiplicative group of the prime field used.

 
size
integer
When type=RSA or type=DSA
Bit size of modulus (RSA) or prime number (DSA).

 
x
integer
When type=ECC
The x coordinate for the public point on the elliptic curve.

 
y
integer
When type=DSA or type=ECC
For type=ECC, this is the y coordinate for the public point on the elliptic curve.
For type=DSA, this is the publicly known group element whose discrete logarithm w.r.t. g is the private key.

type
string
success
The key's type.
One of RSA, DSA, ECC, Ed25519, X25519, Ed448, or X448.
Will start with unknown if the key type cannot be determined.

Sample:
RSA


Authors

  • Felix Fontein (@felixfontein)