如何从 .cer 和 .key 获取 .pfx 文件? [英] How to get .pfx file from .cer and .key?

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

问题描述

在这里提问之前.我已经搜索了很多关于我的问题.而且问题依然存在.以下是我已经阅读过的帖子参考.

错误:无法加载证书

我想要什么?

如何从证书和私钥创建 .pfx 文件?让我知道我在代码中做错了什么.

解决方案

req 命令默认创建证书请求,而不是证书.如果添加 -x509 参数,它将使用提供的密钥对请求进行自签名,并输出证书.然后您应该能够成功创建 .pfx.

Before questioning here. I've searched a lot about my problem. And problem is still exists. Below is the references of posts, which I've already read.

How to create .pfx file from certificate and private key?

Convert a CERT/PEM certificate to a PFX certificate

How to get .pem file from .key and .crt files?

How to generate a .pfx file from a .cer file?

Overview

I'm working on:

Windows 10 64bit

IIS (Version 10.0.16299.15)

I've installed Win32 OpenSSL v1.1.0g

These are the files that I have available:

  • server.cer

  • server.key

What I've tried?

I have also tried various things from trawling through posts but my lack of experience in this area is really impeding my efforts.

Below commands I have tried in Terminal to create my server.key and server.cer file.

set RANDFILE=c:\certificate\.md

set OPENSSL_CONF=c:\OpenSSL-Win32\bin\openssl.cfg

c:\OpenSSL-Win32\bin\openssl.exe genrsa -out server.key 2048`

c:\OpenSSL-Win32\bin\openssl.exe req -new -key server.key -out server.cer -config C:\OpenSSL-Win32\bin\openssl.cfg

c:\OpenSSL-Win32\bin\openssl.exe pkcs12 -export -in server.cer -inkey server.key -out server.pfx

Output

Error: unable to load certificates

What I want?

How to create .pfx file from certificate and private key? Let me know what I'm doing wrong in my code.

解决方案

The req command creates a certificate request by default, not a certificate. If you add the -x509 argument, it will self-sign the request using the provided key, and output a certificate instead. You should then be able to create the .pfx successfully.

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

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