我正在尝试验证有证书交换的客户端。我遇到的问题是openssl客户端拒绝连接尝试,因为身份验证握手中不包含任何证书颁发机构。SSLStream在服务器身份验证上设置可信证书颁发机构
这似乎对在Windows Server 2008 R2上运行的实例正常工作,但在我的两个开发环境(Windows 10和Windows 7)中都失败了。我看过并试图更改几个窗口设置(主要是本地组策略),这可能会阻止添加证书颁发机构,但无法正常工作。
是LocalCertificateSelectionCallback的字符串数组acceptableIssuers字段的函数吗?
我还发现另一个stackoverflow php solution是相关的,但不知道如何将它应用到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);
任何帮助将是很大的appreciated-谢谢!