Hi All,
I basically wanted to run the below command and create those files using ansible community.crypto module.Its not working as expected
openssl pkcs12 -in test.pfx -nocerts -nodes | sed -ne '/-BEGIN PRIVATE KEY-/,/-END PRIVATE KEY-/p' > test.key
openssl pkcs12 -in test.pfx -clcerts -nokeys | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > test.crt
openssl pkcs12 -in test.pfx -cacerts -nokeys -chain | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > cacerts.crt
ansible code:
---
- hosts: localhost
collections:
- kubernetes.core
tasks:
- name: Dump/Parse PKCS#12 file
community.crypto.openssl_pkcs12:
action: parse
force: false
src: XXX.pfx
path: privatekey.pem
privatekey_passphrase: XXX
passphrase: XXXX
state: present
- name: Get information on generated certificate
community.crypto.x509_certificate_info:
path: privatekey.pem
register: result
- name: Dump information
ansible.builtin.debug:
var: result
- name: Get information on generated key
community.crypto.openssl_privatekey_info:
path: privatekey.pem
return_private_key_data: true
register: result
- name: Dump information
ansible.builtin.debug:
var: result