SSLStream 在服务器身份验证上设置受信任的证书颁发机构



我正在尝试对交换证书的客户端进行身份验证。我遇到的问题是 openssl 客户端拒绝连接尝试,因为身份验证握手中不包含证书颁发机构。

对于在Windows Server 2008 R2上运行的实例来说,这似乎工作正常,但是在我的两个开发环境(Windows 10和Windows 7)中,它都失败了。我已经查看并尝试更改了一些窗口设置(主要是本地组策略),这些设置可能会禁止添加证书颁发机构,但无法使其正常工作。

这是字符串数组的函数可接受的本地证书选择回调的颁发者字段吗?

我还找到了另一个相关的stackoverflow php解决方案,但不知道如何将其应用于sslstream类。

我的代码看起来像这样

var _nwStream = new SslStream(client.GetStream(), true,
(sender, certificate, chain, sslPolicyErrors) =>
{
  bool policyErrs = (sslPolicyErrors & (SslPolicyErrors.RemoteCertificateChainErrors | SslPolicyErrors.RemoteCertificateNotAvailable)) != 0;
  if (policyErrs)
  {
    string message = string.Format("Remote Certificate failed for client: {0}, SSL policy errors {1}", client.Client.RemoteEndPoint, sslPolicyErrors);
    return !policyErrs;
},
(sender, targetHost, localCertificates, remoteCertificate, acceptableIssuers) =>
{
  acceptableIssuers = new string[] { _cert.Issuer };
  return _cert;
});
_nwStream.AuthenticateAsServer(_cert, true, System.Security.Authentication.SslProtocols.Tls, true);

任何帮助将不胜感激-谢谢!

好吧,

我不知道为什么它没有早点出现。有一个注册表项在HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL称为 SendTrustedIssuerList,设置为 0,将其更改为 1 解决了该问题。此标志在 Windows Server 实例上可能默认设置为 1。

相关内容

最新更新