2016-08-24 120 views
1

我在与连接到MongoDB的使用C#驱动程序的问题。该代码适用于其他系统,但出于某种原因不想在我的工作。我使用的是最新的Mongo .net驱动程序和core/bson,并且具有正确的连接设置。MongoDB的C#驱动程序“的远程证书无效”

我完全错误是:

A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = ReadPreferenceServerSelector{ ReadPreference = { Mode = Primary, TagSets = [] } }, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "1", ConnectionMode : "Sharded", Type : "Sharded", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/lon-mongos1.objectrocket.com:33138" }", EndPoint: "Unspecified/lon-mongos1.objectrocket.com:33138", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure. 
at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult) 
at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result) 
at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult) 
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization) 
--- End of stack trace from previous location where exception was thrown --- 
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() 
at MongoDB.Driver.Core.Connections.SslStreamFactory.<CreateStreamAsync>d__4.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() 
at MongoDB.Driver.Core.Connections.BinaryConnection.<OpenHelperAsync>d__47.MoveNext() 
--- End of inner exception stack trace --- 
at MongoDB.Driver.Core.Connections.BinaryConnection.<OpenHelperAsync>d__47.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() 
at MongoDB.Driver.Core.Servers.ClusterableServer.<HeartbeatAsync>d__42.MoveNext()" }] }. 

我已经看看进入本地证书并不能看到任何建议是不是在我身边有效。

从非蒙戈背景这个神是不是我太熟悉的东西,但不知道是否有人能够说明什么我可能是错在这里做一些轻?

我运行W7 SP1与VS2015。

编辑:我已经试过不管验证证书的方法,但是这并没有证明任何区别了。

我经常跑提琴手,但我已经删除了小提琴手证书,目前我不运行它。

回答

0

在大多数情况下,当MongoDB使用自签名的SSL证书,它无法通过与本地安装根证书标准审定会出现此错误。如果配置MongoDB的驱动程序用C#代码

sslVerifyCertificate=false 

var client = new MongoClient(); 
client.Settings.VerifySslCertificate = false; 
你可以简单地通过在连接字符串中指定以下查询参数禁用此验证
相关问题