Use OpenSSL to convert a pfx certificate to a certificate in cer format

Source: Internet
Author: User
Tags install openssl openssl download pkcs12 pfx file

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.