繁体   English   中英

连接到Heroku Postgres数据库时出现CertificateUnknown错误

[英]CertificateUnknown error when connecting to Heroku Postgres database

所以我正在从SQL Server迁移到PostgreSQL,我正在为迁移期构建一个临时解决方案,以允许我的ASP.NET应用程序连接到我的Heroku Postgres数据库并使用Entity Framework等。

到目前为止,我已经设法从pgAdmin III连接到数据库的Windows没有问题,但是当从ASP.NET应用程序连接时,我收到此错误:

CertificateUnknown:不接受服务器证书。 链状态:已处理证书链,但终止于信任提供程序不信任的根证书。 证书中不存在指定的主机名。

我仍然是heroku的新手,但是为什么我可以使用与我的ASP.NET应用程序相同的设置从pgAdmin连接它没有意义,但它在应用程序本身中不起作用。

完整堆栈跟踪:

[ClientAlertException:CertificateUnknown:不接受服务器证书。 链状态:已处理证书链,但终止于信任提供程序不信任的根证书。 证书中不存在指定的主机名。]
TlsClientStream.TlsClientStream.SendAlertFatal(AlertDescription description,String message)+44
TlsClientStream.TlsClientStream.ParseCertificateMessage(Byte [] buf,Int32&pos)+1359
TlsClientStream.TlsClientStream.TraverseHandshakeMessages()+415
TlsClientStream.TlsClientStream.GetInitialHandshakeMessages(Boolean allowApplicationData)+336
TlsClientStream.TlsClientStream.PerformInitialHandshake(String hostName,X509CertificateCollection clientCertificates,RemoteCertificateValidationCallback remoteCertificateValidationCallback,Boolean checkCertificateRevocation)+198

[IOException:TlsClientStream.ClientAlertException:CertificateUnknown:不接受服务器证书。 链状态:已处理证书链,但终止于信任提供程序不信任的根证书。 证书中不存在指定的主机名。 at TlsClientStream.TlsClientStream.SendAlertFatal(AlertDescription description,String message)at TlsClientStream.TlsClientStream.ParseCertificateMessage(Byte [] buf,Int32&pos)at TlsClientStream.TlsClientStream.TransHandshakeMessages()at TlsClientStream.TlsClientStream的TlsClientStream.TlsClientStream.GetInitialHandshakeMessages(Boolean allowApplicationData) .PerformInitialHandshake(String hostName,X509CertificateCollection clientCertificates,RemoteCertificateValidationCallback remoteCertificateValidationCallback,Boolean checkCertificateRevocation)]
TlsClientStream.TlsClientStream.PerformInitialHandshake(String hostName,X509CertificateCollection clientCertificates,RemoteCertificateValidationCallback remoteCertificateValidationCallback,Boolean checkCertificateRevocation)+289
Npgsql.NpgsqlConnector.RawOpen(NpgsqlTimeout timeout)+1372
Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout)+314
Npgsql.NpgsqlConnection.OpenInternal()+ 461
Npgsql.NpgsqlConnection.Open()+ 4
Npgsql.NpgsqlServices.UsingPostgresDBConnection(NpgsqlConnection连接,Action`1动作)+162
Npgsql.NpgsqlServices.GetDbProviderManifestToken(DbConnection连接)+99
System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection连接)+87

[ProviderIncompatibleException:提供程序未返回ProviderManifestToken字符串。]
System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)+271
System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices,DbConnection connection)+27

[ProviderIncompatibleException:访问数据库时出错。 这通常意味着与数据库的连接失败。 检查连接字符串是否正确,以及是否使用了相应的DbContext构造函数来指定它或在应用程序的配置文件中找到它。 有关DbContext和连接的信息,请参阅http://go.microsoft.com/fwlink/?LinkId=386386 有关失败的详细信息,请参阅内部异常。]
System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices,DbConnection connection)+89
System.Data.Entity.Infrastructure。<> c__DisplayClass1.b__0(元组3 k) +31
System.Collections.Concurrent.ConcurrentDictionary
3 k) +31
System.Collections.Concurrent.ConcurrentDictionary
3 k) +31
System.Collections.Concurrent.ConcurrentDictionary
2.GetOrAdd(TKey key,Func 2 valueFactory) +62
System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection connection) +251
System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) +56
System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +43
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +62
System.Data.Entity.Internal.RetryLazy
2 valueFactory) +62
System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection connection) +251
System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) +56
System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +43
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +62
System.Data.Entity.Internal.RetryLazy
2 valueFactory) +62
System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection connection) +251
System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) +56
System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +43
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +62
System.Data.Entity.Internal.RetryLazy
2.GetValue(TInput input)+123

System.Data.Entity.Internal.LazyInternalContext.InitializeContext()+627 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)+18
System.Data.Entity.Internal.Linq.InternalSet 1.Initialize() +53
System.Data.Entity.Internal.Linq.InternalSet
1.Initialize() +53
System.Data.Entity.Internal.Linq.InternalSet
1.Initialize() +53
System.Data.Entity.Internal.Linq.InternalSet
1.get_InternalContext()+15 System.Data.Entity.Infrastructure.DbQuery 1.System.Linq.IQueryable.get_Provider() +38 System.Linq.Queryable.Where(IQueryable 1源,表达式1 predicate) +83
Saleboat.Logic.MeetingLogic.CheckMeetingFilter.OnActionExecuting(ActionExecutingContext filterContext) in C:\\Users\\Michael\\Documents\\Visual Studio 2013\\Projects\\Saleboat\\project-saleboat\\Saleboat\\Logic\\MeetingLogic\\CheckMeetingFilter.cs:22 System.Web.Mvc.Async.AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive(Int32 filterIndex) +176
System.Web.Mvc.Async.AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive(Int32 filterIndex) +644
System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__31(AsyncCallback asyncCallback, Object asyncState) +58
System.Web.Mvc.Async.WrappedAsyncResult
1 predicate) +83
Saleboat.Logic.MeetingLogic.CheckMeetingFilter.OnActionExecuting(ActionExecutingContext filterContext) in C:\\Users\\Michael\\Documents\\Visual Studio 2013\\Projects\\Saleboat\\project-saleboat\\Saleboat\\Logic\\MeetingLogic\\CheckMeetingFilter.cs:22 System.Web.Mvc.Async.AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive(Int32 filterIndex) +176
System.Web.Mvc.Async.AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive(Int32 filterIndex) +644
System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__31(AsyncCallback asyncCallback, Object asyncState) +58
System.Web.Mvc.Async.WrappedAsyncResult
1 predicate) +83
Saleboat.Logic.MeetingLogic.CheckMeetingFilter.OnActionExecuting(ActionExecutingContext filterContext) in C:\\Users\\Michael\\Documents\\Visual Studio 2013\\Projects\\Saleboat\\project-saleboat\\Saleboat\\Logic\\MeetingLogic\\CheckMeetingFilter.cs:22 System.Web.Mvc.Async.AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive(Int32 filterIndex) +176
System.Web.Mvc.Async.AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive(Int32 filterIndex) +644
System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__31(AsyncCallback asyncCallback, Object asyncState) +58
System.Web.Mvc.Async.WrappedAsyncResult
1.CallBeginDelegate(AsyncCallback callback,Object callbackState)+14

System.Web.Mvc.Async.WrappedAsyncResultBase 1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeActionMethodWithFilters(ControllerContext controllerContext, IList
1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeActionMethodWithFilters(ControllerContext controllerContext, IList
1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeActionMethodWithFilters(ControllerContext controllerContext, IList
1过滤器,ActionDescriptor actionDescriptor,IDictionary 2 parameters, AsyncCallback callback, Object state) +197
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__19(AsyncCallback asyncCallback, Object asyncState) +743
System.Web.Mvc.Async.WrappedAsyncResult
2 parameters, AsyncCallback callback, Object state) +197
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__19(AsyncCallback asyncCallback, Object asyncState) +743
System.Web.Mvc.Async.WrappedAsyncResult
2 parameters, AsyncCallback callback, Object state) +197
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__19(AsyncCallback asyncCallback, Object asyncState) +743
System.Web.Mvc.Async.WrappedAsyncResult
1.CallBeginDelegate(AsyncCallback callback,Object callbackState)+14

System.Web.Mvc.Async.WrappedAsyncResultBase 1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +343
System.Web.Mvc.Controller.<BeginExecuteCore>b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +25
System.Web.Mvc.Async.WrappedAsyncVoid
1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +343
System.Web.Mvc.Controller.<BeginExecuteCore>b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +25
System.Web.Mvc.Async.WrappedAsyncVoid
1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +343
System.Web.Mvc.Controller.<BeginExecuteCore>b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +25
System.Web.Mvc.Async.WrappedAsyncVoid
1.CallBeginDelegate(AsyncCallback callback,Object callbackState)+30

System.Web.Mvc.Async.WrappedAsyncResultBase 1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +465
System.Web.Mvc.Controller.<BeginExecute>b__14(AsyncCallback asyncCallback, Object callbackState, Controller controller) +18
System.Web.Mvc.Async.WrappedAsyncVoid
1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +465
System.Web.Mvc.Controller.<BeginExecute>b__14(AsyncCallback asyncCallback, Object callbackState, Controller controller) +18
System.Web.Mvc.Async.WrappedAsyncVoid
1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +465
System.Web.Mvc.Controller.<BeginExecute>b__14(AsyncCallback asyncCallback, Object callbackState, Controller controller) +18
System.Web.Mvc.Async.WrappedAsyncVoid
1.CallBeginDelegate(AsyncCallback callback,Object callbackState)+20

System.Web.Mvc.Async.WrappedAsyncResultBase 1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +374
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +16
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +52 System.Web.Mvc.Async.WrappedAsyncVoid
1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +374
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +16
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +52 System.Web.Mvc.Async.WrappedAsyncVoid
1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +374
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +16
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +52 System.Web.Mvc.Async.WrappedAsyncVoid
1.CallBeginDelegate(AsyncCallback callback,Object callbackState)+30

System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback回调,对象状态,Int32超时)+128
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext,AsyncCallback回调,对象状态)+384
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext,AsyncCallback回调,对象状态)+48
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context,AsyncCallback cb,Object extraData)+16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+ 103 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean&completedSynchronously)+155

使用Npgsql 3.1.5尝试在连接字符串中使用“Trust Server Certificate = true”。 连接字符串示例:

Server=[servername];Port=[port];User Id=[username];Password=[password];Database=[databasename];sslmode=Require;Trust Server Certificate=true

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM