2016-08-24 106 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; 
你可以簡單地通過在連接字符串中指定以下查詢參數禁用此驗證
相關問題