我有一个 WCF 服务,我想使用 SSL 访问它。我在我的开发机器上,所以我在考虑自托管服务。我一直在关注 Configuring HTTP and HTTPS .
我创建了一个自签名证书,并将其添加到 Trusted Root Certification Authorities。我已经创建了另外两个由第一个签名的证书,一个用于客户端,另一个用于服务器。我关注了 Using makecert to create certificates for development .
我无法通过 SSL 证书配置步骤。当我使用 netsh 将证书绑定(bind)到端口号时它抛出一个 SSL 错误:
Certificate add failed, Error: 1312 A specified logon session does not exist. It may already have been terminated.
证书是否需要一些特殊字段或其他东西才能工作?
CA证书:
makecert -n "CN=TestCA" -cy authority -a sha1 -sv "TestCA.pvk" -r "TEST_CA.cer"
服务证书:
makecert -n "CN=rneapp.com" -ic "TEST_CA.cer" -iv "TestCA.pvk" -a sha1 -sky exchange -pe -sv "rneapp.com.pvk" "rneapp.com.cer"
客户端证书:
makecert -n "CN=rneClient" -ic "TEST_CA.cer" -iv "TestCA.pvk" -a sha1 -sky exchange -pe -sv "rneClient.pvk" "rneClient.cer"
我正在使用此命令将证书绑定(bind)到端口:
netsh http add sslcert ipport=0.0.0.0:8465 certhash=a853f3b5b48b8a506bdc4212ba2726a3bfea2bb6 appid={2E53B9B0-17AE-4EBC-A1AE-43D53A6FD07D} clientcertnegotiation=enable
最佳答案
当我遇到同样的问题时,将证书从当前用户移动到本地计算机存储会有所帮助,因此请尝试检查您的证书存储。
netsh http add sslcert
的内置帮助也提到了关于 certstorename
选项的这一点:
certstorename - Store name for the certificate. Defaults
to MY. Certificate must be stored in the
local machine context.
关于wcf - 使用 SSL 和 WCF 自托管 - 无法将证书绑定(bind)到端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6228003/