簡體   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