【问题标题】:(offline) validation for a SSL ConnectionSSL 连接的(离线)验证
【发布时间】: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


    【解决方案1】:

    ...带有常见 CA 根证书指纹的列表。

    ...从这个 CA 根证书到颁发的证书的链是无效的

    您可以检查证书是否与指纹匹配,但您无法仅通过指纹验证证书(链)之间的关系。链的验证是通过验证证书上的签名来完成的,为此,您需要包含在签名者证书中的签名者公钥。

    除此之外,我假设 C# 具有根据您自己的一组受信任的 CA 验证证书链的必要方法,因此您无需添加自己的验证回调。

    【讨论】:

      猜你喜欢
      • 2019-08-11
      • 1970-01-01
      • 1970-01-01
      • 2019-08-06
      • 1970-01-01
      • 2014-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多