I am trying to generate a PKCS12 file using Ansible openssl_pkcs12
module. I am successfully able to generate the certificate but when I am trying to import it to tlsKeyStore
in my CentOS VM or open manually it always says invalid password. But the password is correct.
But if I generate the same PKCS12 certificate manually using openssl
command from the same CentOS VM, I am able to import it to the tlsKeyStore
and can open as well with the same password.
Below is the snippet of code:
- name: Generate PKCS#12 file
openssl_pkcs12:
action: export
path: server_cert-ca.p12
friendly_name: Test
passphrase: xxxx
privatekey_path: server-privatekey.pem
certificate_path: server_cert.pem
state: present
loop: "{{ my_list }}"
Below is the Error while importing:
keytool -importkeystore -srckeystore server_cert-ca.p12 -srcstoretype pkcs12 -destkeystore tlsKeyStore -deststoretype jks
Importing keystore server_cert-ca.p12 to tlsKeyStore...
Enter destination keystore password:
Re-enter new password:
Enter source keystore password:
keytool error: java.io.IOException: keystore password was incorrect
Could someone comment whether there is something wrong with this Ansible module?
2
Answers
Thanks for testing...Eventually I fixed the issue by reinstalling my ansible in a Virtual env and also I set the keytool env variable as below:
A minimal example playbook
pkcs12.yaml
will result into a P12 file generated and further results
To summarize, I am not able to reproduce an issue.