A certificate in pfx format needs to be converted to the CER format at work. The original practice is to first import the pfx format certificate to the browser, and then export it from the browser, however, this is too slow for batch operations. You can use the commands provided by OpenSSL to meet this requirement.
OpenSSL download: (Windows)
Http://dl.pconline.com.cn/download/355862.html
Install OpenSSL and run the following command in the bin directory to complete the conversion:
OpenSSL PKCS12-nodes-nokeys-In 1.pfx-passin pass: Certificate password-out 1.cer
If you do not need to encrypt the private key in PEM, you can add option-nodes;
If you do not need to export the private key, you can add the option-nokeys;
If the message "Warning: Can't open config file:/usr/local/SSL/OpenSSL. CNF" appears ",
Enter "set openssl_conf = OpenSSL. cfg ".
Attach a bat for batch conversion
Install OpenSSL first. The pfx file and password file must be the same. For example:
Certificate. pfx
Certificate .txt (password file)
@echo off&setlocal enabledelayedexpansionset /p mulu=请将pfx所放文件夹拖进本窗口:set openssl=C:\OpenSSL-Win32\binclsfor /r %mulu% %%i in (*.pfx) do (set pfxname=%%~niset fname=%%iset passfile=!fname:~0,-4!.txtecho !pfxname!::echo !passfile!set /p pass=<!passfile!::echo !pass!set OPENSSL_CONF=%openssl%openssl.cfg%openssl%openssl pkcs12 -nodes -nokeys -in !fname:~0,-4!.pfx -passin pass:!pass! -out !fname:~0,-4!.cer)echo 转换完毕.!pause>nul
Use OpenSSL to convert a pfx certificate to a certificate in cer format