如何从证书和私钥创建 .pfx 文件? [英] How to create .pfx file from certificate and private key?

查看:51
本文介绍了如何从证书和私钥创建 .pfx 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要 .pfx 文件才能在 IIS 上的网站上安装 https.

I need .pfx file to install https on website on IIS.

我有两个单独的文件:证书(.cer 或 pem)和私钥 (.crt),但 IIS 只接受 .pfx 文件.

I have two separate files: certificate (.cer or pem) and private key (.crt) but IIS accepts only .pfx files.

我显然安装了证书,它在证书管理器 (mmc) 中可用,但是当我选择证书导出向导时,我无法选择 PFX 格式(显示为灰色)

I obviously installed certificate and it is available in certificate manager (mmc) but when I select Certificate Export Wizard I cannot select PFX format (it's greyed out)

是否有任何工具可以做到这一点或以编程方式做到这一点的 C# 示例?

Are there any tools to do that or C# examples of doing that programtically?

推荐答案

您将需要使用 openssl.

You will need to use openssl.

openssl pkcs12 -export -out domain.name.pfx -inkey domain.name.key -in domain.name.crt

密钥文件只是一个文本文件,其中包含您的私钥.

The key file is just a text file with your private key in it.

如果你有一个根 CA 和中间证书,那么也使用多个 -in 参数来包含它们

If you have a root CA and intermediate certs, then include them as well using multiple -in params

openssl pkcs12 -export -out domain.name.pfx -inkey domain.name.key -in domain.name.crt -in middle.crt -in rootca.crt

您可以从这里安装 openssl:openssl

You can install openssl from here: openssl

这篇关于如何从证书和私钥创建 .pfx 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆