- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
如下所示,RemoteCertificateValidationCallback
委托(delegate)用于验证远程安全套接字层 (SSL) 证书。 certificate
参数是远程服务器返回的终端实体服务器证书。我不确定的是 chain
参数是如何构造的。它是根据远程服务器返回的证书列表构建的(通常是服务器证书和中间 CA 证书),还是转到证书本地存储并尝试为 certificate
参数中返回的终端实体服务器证书构建链?
// The following method is invoked by the RemoteCertificateValidationDelegate.
public static bool ValidateServerCertificate(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
...
}
更新
我怀疑它正在使用 X509Chain.Build(server_cert),但想知道到底发生了什么。
这个人看到了类似的东西:c# Retrieving a Certificate from an SSL stream shows different chain results vs other external tools来自 SSL 流的证书显示不同的链结果
最佳答案
它作为 TLS handshake 的一部分从服务器接收:
7.4.2. Server Certificate
When this message will be sent:
The server MUST send a Certificate message whenever the agreed-upon key exchange method uses certificates for authentication(this includes all key exchange methods defined in this documentexcept DH_anon). This message will always immediately follow theServerHello message.
Meaning of this message:
This message conveys the server's certificate chain to the client.
The certificate MUST be appropriate for the negotiated ciphersuite's key exchange algorithm and any negotiated extensions.
Structure of this message:
opaque ASN.1Cert<1..2^24-1>;
struct {
ASN.1Cert certificate_list<0..2^24-1>;
} Certificate;certificate_list
This is a sequence (chain) of certificates. The sender'scertificate MUST come first in the list. Each followingcertificate MUST directly certify the one preceding it. Becausecertificate validation requires that root keys be distributedindependently, the self-signed certificate that specifies the rootcertificate authority MAY be omitted from the chain, under theassumption that the remote end must already possess it in order tovalidate it in any case.
嗯,根据X509Chain.BuildChain()
它使用 CAPI CertGetCertificateChain
,这意味着取自本地证书存储,由给定证书构建。您可以在 TransportSecurityHelpers.cs
中看到如何调用验证回调.链内置_SecureChannel.VerifyRemoteCertificate
:
chain = new X509Chain();
chain.ChainPolicy.RevocationMode = m_CheckCertRevocation? X509RevocationMode.Online : X509RevocationMode.NoCheck;
chain.ChainPolicy.RevocationFlag = X509RevocationFlag.ExcludeRoot;
if (remoteCertificateStore != null)
chain.ChainPolicy.ExtraStore.AddRange(remoteCertificateStore);
if (!chain.Build(remoteCertificateEx) // Build failed on handle or on policy
&& chain.ChainContext == IntPtr.Zero) // Build failed to generate a valid handle
{
throw new CryptographicException(Marshal.GetLastWin32Error());
}
所以看起来 .Net 从 SSL 上下文中获取服务器证书并使用 CAPI 链构建函数构建链。
关于c# - RemoteCertificateValidationCallback Delegate 中的 X509Chain 参数是如何构建的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25504996/
我和这里有同样的问题:How to disable "Security Alert" window in Webbrowser control 我喜欢这个答案,但我要将 ServicePointMan
我有以下代码尝试根据私有(private) PKI 中的 CA 验证服务器证书。它与 ServicePointManager 和 RemoteCertificateValidationCallback
我的 Windows 服务正在尝试连接到由证书 C 签名的网站。C 由 Symantec Class 3 Secure Server CA - G4(中间 CA)签名,Symantec Class 3
我正在尝试修复现有的 .Net 2.0 服务/应用程序。 这是一个接受 SSL/TLS 连接的 TCP 服务器。正如预期的那样,在端口 443 上运行。它用于响应 Yealink 配置请求。您可以在手
X509Certificate2 certificate = new X509Certificate2(); FileStream fileStream = File.Open(@"C:\op
如下所示,RemoteCertificateValidationCallback 委托(delegate)用于验证远程安全套接字层 (SSL) 证书。 certificate参数是远程服务器返回的终端
H 所有, SMPT 通信不适用于启用的 SSL 配置。 我正在通过 SMTP 发送电子邮件,它运行良好。但是,当我启用 SSL 后,它无法正常工作,并在 RemoteCertificateValid
我是一名优秀的程序员,十分优秀!