【问题标题】:How to set up client certificate validation in mongodb SSL如何在 mongodb SSL 中设置客户端证书验证
【发布时间】:2014-02-03 20:29:34
【问题描述】:

我编写了下面的代码来在 mongodb 中实现 SSL 中的客户端认证验证。但下面的代码抛出“ mscorlib.dll 中出现了“System.Security.Cryptography.CryptographicException”类型的第一次机会异常”。

字符串文件名 = "C://mongodb-cert.cert";

clientSettings.UseSsl = connectInfo.EnableSSL;

System.Security.Cryptography.X509Certificates.X509Certificate2 cert = new System.Security.Cryptography.X509Certificates.X509Certificate2(filename);

clientSettings.SslSettings.ClientCertificates = new List(){cert};

MongoClient mongoClient = new MongoClient(clientSettings);

谁能看一下代码,让我知道是什么导致代码抛出异常。

提前致谢。

--Vibhu

【问题讨论】:

    标签: ssl


    【解决方案1】:

    可能是你的文件名吗?

    String filename = "C://mongodb-cert.cert";
    

    应该是:

    String filename = "C:\\mongodb-cert.cert";
    

    注意反斜杠 \\ 而不是正斜杠 //

    【讨论】:

      猜你喜欢
      • 2013-10-01
      • 1970-01-01
      • 2016-05-24
      • 1970-01-01
      • 2017-05-18
      • 2013-05-29
      • 2015-08-07
      • 2013-08-04
      • 2013-02-08
      相关资源
      最近更新 更多