绑定到端口时 SSL 证书添加失败 [英] SSL Certificate add failed when binding to port

查看:27
本文介绍了绑定到端口时 SSL 证书添加失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 WCF 创建了一个 WebService.我正在做自托管,我想启用 HTTPS.根据我对这种情况的理解,我需要创建一个证书并绑定到我想要使用的端口.

I created a WebService using WCF. I'm doing self hosting and I want to enable HTTPS. From my understanding for this to happen, I need to create a certificate and bind to the port that I want to use.

以下是我为处理此问题所做的步骤:

Here are the steps that I've done to handle this:

  1. 在我的本地机器上创建了一个证书作为根证书颁发机构
    • makecert -n "CN=My Root Certificate Authority" -r -sv RootCATest.pvk RootCATest.cer
  • makecert -sk MyKeyName -iv RootCATest.pvk -n "CN=MyMachineName" -ic RootCATest.cer -sr localmachine -ss my -sky exchange -pe MyMachineName.cer

从签署的根证书颁发机构创建了一个临时服务证书

Created a temporary service certificate from the signed Root Certificate Authority

  • makecert -sk MyKeyName -iv RootCATest.pvk -n "CN=MyMachineName" -ic RootCATest.cer -sr localmachine -ss my -sky exchange -pe MyMachineName.cer

尝试将证书绑定到端口号(在本例中为 443)

Tried to Bind the Certificate to the Port number (443 in this case)

  • netsh http add sslcert ipport=0.0.0.0:443 certhash=2c5ba85bcbca412a74fece02878a44b285c63981 appid={646937c0-1042-4e81-a3b7}8dli>
  • netsh http add sslcert ipport=0.0.0.0:443 certhash=2c5ba85bcbca412a74fece02878a44b285c63981 appid={646937c0-1042-4e81-a3b6-47d678d68ba9}

第 4 步的结果是以下错误:

The result from step 4 is the following error:

SSL 证书添加失败,错误 1312

SSL Certificate add failed, Error 1312

指定的登录会话不存在.它可能已经被终止.

A specified logon session does not exist. It may already have been terminated.

有人知道我为什么会收到这个错误吗?

Does anyone have a clue why I might be getting this error?

推荐答案

我遇到了同样的错误.第一次发生时,正如 Micheal 所说,我不得不将证书移到 Certificates(Local Computer) -->Personal -->Certificate 文件夹下.当我在另一台机器上导入相同的证书时,我遇到了同样的错误.原因是我使用 certmgr.msc 导入证书..因此打开的窗口显示证书 - 当前用户".使用此窗口导入的证书会导致 netsh 失败并显示 1312 错误.确保在 MMC 中使用证书管理单元来导入证书.MMC 的证书管理单元显示证书(本地计算机)".这让 netsh 执行顺利通过.

I had the same error. The first time it occurred, as Micheal said, I had to move the certificate under Certificates(Local Computer) -->Personal -->Certificate folder. I had the same error when I imported the same certificate on another machine. The reason was that I was using certmgr.msc to import the certificate. . The window opened thus shows "Certificates – Current User". Certificates imported using this window cause netsh to fail with the 1312 error. Make sure to use certificate snap-in in MMC to import certificates. The certificate snap-in from MMC shows "Certificates (Local Computer)". This lets the netsh execution sail through.

这篇关于绑定到端口时 SSL 证书添加失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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