In Git-Bash-Windows `openssl pkcs12` does not prompt for password

Viewed 4698

The SSL certificate authority sent me the signed certificate in .pfx format and it was password-protected; so I need to convert it to .crt file.

The first attempt was to call openssl pkcs12 -in server.pfx -out server.crt -nokeys -clcerts, simply in Git-Bash Windows; but it waits forever, and there was no output nor hint. Eventually, I switched to Linux (RHEL7), and the same command worked OK. It turns out, in Linux the command prompts "Enter Import Password:"; however, running in Windows Git-Bash the it's missing the prompt for password, and will be hanging there forever.

I'm wondering if there is anything to make it work in Windows Git-Bash, e.g. command argument, etc., as my work computer is still running Windows OS. Any pointers will be highly appreciated.

Screenshot of Linux:

[root@host]# openssl pkcs12 -in server.pfx -out server.crt -nokeys -clcerts
Enter Import Password:
MAC verified OK
[root@host]#
2 Answers

First, on Windows 10, you could switch to any Linus distro of your choice through WSL2.

Second, on Windows, I always had to include the password in the command line:

openssl pkcs12 -password pass:aPassword -in server.keystore.pfx -nokeys -clcerts -out server.cert
# or
openssl pkcs12 -passin pass:aPassword -in server.keystore.pfx -nokeys -clcerts -out server.cert

On Git-Bash, you have to use winpty in front; e.g.,

$ winpty openssl pkcs12 -in server.keystore.pfx -nokeys -clcerts -out server.cert
Related