2

我必须为对等通信而不是本地主机(从一台机器到另一台机器)进行相互 SSL 身份验证。这是使用 Microsoft.Net套接字通信类以及具有ValidateServerCertificateValidateClientCertificate回调的SslStreamBeginAuthenticateAsServerBeginAuthenticateAsClient异步完成的。为此,我创建了自签名证书,包括

• 根证书

• 服务器证书

• 客户证书

为了生成上述证书,我将 makecert.exe 和 pvk2pfx.exe 放在一个文件夹中,然后运行以下命令。

根证书创建命令

- 创建 .cer 并生成私钥

makecert.exe -n "CN=abc.com" -r -pe -a sha512 -len 4096 -sky 签名 -cy authority -sv RootCert.pvk RootCert.cer

- 使用 .cer 和私钥创建 .pfx

pvk2pfx -pvk RootCert.pvk -spc RootCert.cer -pfx RootCert.pfx -po test123

服务器证书创建命令

- 创建 .cer 并生成私钥

makecert.exe -pe -n "CN=abc.com" -a sha512 -sky exchange -eku 1.3.6.1.5.5.7.3.1 -ic RootCert.cer -iv RootCert.pvk -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 -sv ServerCert.pvk ServerCert.cer

- 使用 .cer 和私钥创建 .pfx

pvk2pfx -pvk ServerCert.pvk -spc ServerCert.cer -pfx ServerCert.pfx -po test123

客户端证书创建命令

- 创建 .cer 并生成私钥

makecert.exe -pe -n "CN=abc.com" -a sha512 -sky exchange -eku 1.3.6.1.5.5.7.3.2 -ic RootCert.cer -iv RootCert.pvk -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 -sv ClientCert.pvk ClientCert.cer

- 使用 .cer 和私钥创建 .pfx

pvk2pfx -pvk ClientCert.pvk -spc ClientCert.cer -pfx ClientCert.pfx -po test123

对于相互对等身份验证,我需要将这些证书放在 MMC 控制台的什么位置?我需要在本地机器存储或当前用户存储中安装这些吗?

提前致谢

4

1 回答 1

0

根证书必须安装在计算机存储 (LocalMachine\Root) 的 Trusted Root CAs 容器中,并且身份验证证书必须安装在计算机存储的个人容器 (LocalMachine\My) 中。

顺便说一句,makecert.exe 是不推荐使用的工具,即使用于测试也不推荐使用。相反,您应该考虑使用 CertEnroll COM 接口、certreq.exe 工具(带有模板化 INF 文件)或使用New-SelfSignedCertificate PowerShell cmdlet。请注意,此 cmdlet 使用 CNG 密钥存储提供程序,因此它可能无法在 .NET 本机中使用。

PowerShell 中 CertEnroll COM 接口使用的一个示例在我的博客文章中:使用 PowerShell 的自签名证书创建和TechNet Gallery上的更新版本。

于 2014-10-31T07:37:33.217 回答