【发布时间】:2015-01-27 08:28:34
【问题描述】:
假设您有一个只能连接到一个端点的网络客户端,即 HTTPS 网络服务器。使用的证书始终来自证书颁发机构 (CA)。
我的动机是确保使用的证书是从受托方颁发的。 因为软件应该在没有更新的情况下运行并处理新证书,所以证书固定不是一种选择。
在 C# 中,您可以使用回调来使用我们自己的验证
ServicePointManager.ServerCertificateValidationCallback
我得到了用过的 X509Certificate 和 X509Chain。
// Summary:
// Verifies the remote Secure Sockets Layer (SSL) certificate used for authentication.
//
// Parameters:
// sender:
// An object that contains state information for this validation.
//
// certificate:
// The certificate used to authenticate the remote party.
//
// chain:
// The chain of certificate authorities associated with the remote certificate.
//
// sslPolicyErrors:
// One or more errors associated with the remote certificate.
//
// Returns:
// A System.Boolean value that determines whether the specified certificate
// is accepted for authentication.
public delegate bool RemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors);
我的想法是使用常见 CA 根证书指纹列表注册软件。 然后测试 X509Chain
- 一个证书具有相同的指纹(作为通用 CA 根证书)
- 从这个 CA 根证书到颁发的证书的链是无效的
- 证书及时有效(忽略撤销,因为
我的问题
- 谁有更好的主意?
- 如何证明链是有效的?
【问题讨论】:
标签: c# web-services ssl ssl-certificate x509certificate