Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MongoDB C#驱动程序和x27;远程证书无效';_C#_Mongodb - Fatal编程技术网

MongoDB C#驱动程序和x27;远程证书无效';

MongoDB C#驱动程序和x27;远程证书无效';,c#,mongodb,C#,Mongodb,我在使用C#驱动程序连接MongoDB时遇到问题。该代码可以在其他系统上运行,但出于某种原因,不想在我的系统上运行。我正在使用最新的Mongo.net驱动程序和core/bson,并且具有正确的连接设置 我的全部错误是: A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = ReadPreferenceServerSelector{ ReadPreference

我在使用C#驱动程序连接MongoDB时遇到问题。该代码可以在其他系统上运行,但出于某种原因,不想在我的系统上运行。我正在使用最新的Mongo.net驱动程序和core/bson,并且具有正确的连接设置

我的全部错误是:

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()" }] }.
30000ms使用CompositeServerSelector{Selectors=ReadPreferenceServerSelector{ReadPreference={Mode=Primary,TagSets=[]}},LatencyMitingServerSelector{AllowedLatencyRange=00:00.0150000}选择服务器后发生超时。群集状态的客户端视图为{ClusterId:“1”,连接模式:“Sharded”,类型:“Sharded”,状态:“Disconnected”,服务器:[{ServerId:{ClusterId:1,端点:“Unspecified/lon-mongos1.objectrocket.com:33138”},端点:“Unspecified/lon-mongos1.objectrocket.com:33138”,状态:“Disconnected”,类型:“Unknown”,异常:“MongoDB.Driver.MongoConnectionException:打开与服务器的连接时发生异常。-->System.Security.Authentication.AuthenticationException:根据验证过程,远程证书无效。
位于System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult-lazyResult)
位于System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult结果)
位于System.Net.Security.SslStream.EndAuthenticateTaseClient(IAsyncResult asyncResult)
在System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar、Func`2 endFunction、Action`1 endAction、Task`1 Promission、Boolean requiresSynchronization)
---来自引发异常的上一个位置的堆栈结束跟踪---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()中
在MongoDB.Driver.Core.Connections.SslStreamFactory.d_u4.MoveNext()中
---来自引发异常的上一个位置的堆栈结束跟踪---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()中
在MongoDB.Driver.Core.Connections.BinaryConnection.d_u47.MoveNext()中
---内部异常堆栈跟踪的结束---
在MongoDB.Driver.Core.Connections.BinaryConnection.d_u47.MoveNext()中
---来自引发异常的上一个位置的堆栈结束跟踪---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()中
在MongoDB.Driver.Core.Servers.ClusterableServer.d_u42.MoveNext()“}]}中。
我已经在本地查看了证书,没有发现任何迹象表明我的证书无效

来自非蒙哥人的背景,这不是我太熟悉的东西,但我想知道是否有人能解释一下我在这里可能做错了什么

我正在用VS2015运行W7 SP1

编辑:我已经尝试了验证证书的方法,但这也没有证明有任何区别


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

< P>在大多数情况下,当MangGDB使用自签名SSL证书时,出现错误,它不能通过在本地安装的根证书进行标准验证。您可以通过指定以下查询PAR来禁用该验证连接字符串中的参数:

sslVerifyCertificate=false
如果使用c#代码配置MongoDb驱动程序:

var client = new MongoClient();
client.Settings.VerifySslCertificate = false;