community.crypto.openssl_pkcs12_info module – Return certificates and (optionally) private key of a PKCS#12 file

Note

This module is part of the community.crypto collection (version 3.5.1).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.crypto. You need further requirements to be able to use this module, see Requirements for details.

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

New in community.crypto 3.4.0

Synopsis

  • This module loads an PKCS#12 file and returns the contained certificates.

  • If return_private_key=true, the private key (if contained) is also returned.

Requirements

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

  • cryptography >= 3.3

Parameters

Parameter

Comments

content

string

Base64 encoded contents of a PKCS#12 file.

Either path or content must be specified, but not both.

passphrase

string

The PKCS#12 password.

path

path

Filename to read the PKCS#12 file from.

Either path or content must be specified, but not both.

return_private_key

boolean

Whether to return the private key as privatekey.

Avoid returning this unless needed.

Choices:

  • false ← (default)

  • true

Attributes

Attribute

Support

Description

check_mode

Support: full

This action does not modify state.

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: N/A

This action does not modify state.

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

idempotent

Support: full

This action does not modify state.

When run twice in a row outside check mode, with the same arguments, the second invocation indicates no change.

This assumes that the system controlled/queried by the module has not changed in a relevant way.

See Also

See also

community.crypto.x509_certificate_info

Provide information of OpenSSL X.509 certificates.

community.crypto.openssl_pkcs12

Generate OpenSSL PKCS#12 archive.

community.crypto.openssl_pkcs12_extract

Extract certificate and private key from PKCS#12 archive.

Examples

---
- name: Obtain certificates from PKCS#12 file
  community.crypto.openssl_pkcs12_info:
    path: /opt/certs/ansible.p12
  register: result

Return Values

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

Key

Description

certificate

string

Certificate associated to the private key in the PKCS#12 archive in PEM format.

If no private key is contained in the archive, this has value null.

Returned: success

Sample: "-----BEGIN CERTIFICATE-----\nMIIBljCCATugAw..."

friendly_name

string

“Friendly name” of the certificate and private key pair.

If no private key is contained in the archive, this has value null.

Returned: success

Sample: "keypair"

other_certificates

list / elements=string

Other certificates (not associated to the private key) in the PKCS#12 archive in PEM format.

Returned: success

Sample: ["-----BEGIN CERTIFICATE-----\nMIIBljCCATugAw..."]

privatekey

string

The PKCS#12 archive’s private key in PEM format, if present.

Only returned if return_private_key=true.

Note on ansible-core 2.22+, this will be registered as a secret. See Masking secrets in Ansible output for more information.

Returned: success if return_private_key=true

Authors

  • Felix Fontein (@felixfontein)