I am in the process of rotating certificates on an on-premise version of D365FO. I changed the certificates and I tried to reinstall the LocalAgent using the new certificates(client, server and serviceprincipal) and it highlighted CertificateNotMatched with the following error.
PS C:\Infrastructure\Scripts\LocalAgent26> .\LocalAgentCLI.exe Install .\localagent-config.json
Invoking ef6.exe database update --assembly OrchestrationService.DataModels.dll --connection-string "Data Source='xxxxx';Initial Catalog = 'xxxxx'; Integrated Security = True; MultipleActiveResultSets=True" --connection-provider Sys
tem.Data.SqlClient --project-dir C:\Infrastructure\Scripts\LocalAgent26
LocalAgentCLI.exe Error: 0 : Exception System.AggregateException: One or more errors occurred. ---> System.Fabric.FabricServerAuthenti
cationFailedException: FABRIC_E_SERVER_AUTHENTICATION_FAILED: CertificateNotMatched ---> System.Runtime.InteropServices.COMException:
Exception from HRESULT: 0x80071C44
at System.Fabric.Interop.NativeClient.IFabricClusterManagementClient12.EndGetClusterManifest2(IFabricAsyncOperationContext context)
at System.Fabric.FabricClient.ClusterManagementClient.GetClusterManifestAsyncEndWrapper(IFabricAsyncOperationContext context)
at System.Fabric.Interop.AsyncCallOutAdapter2`1.Finish(IFabricAsyncOperationContext context, Boolean expectedCompletedSynchronously
)
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at SetupInfrastructure.ServiceFabricApplicationSetupManager`1.<GetImageStoreParameters>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at SetupInfrastructure.ServiceFabricApplicationSetupManager`1.<Deploy>d__24.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at LocalAgentCLI.Program.Main(String[] args)
---> (Inner Exception #0) System.Fabric.FabricServerAuthenticationFailedException: FABRIC_E_SERVER_AUTHENTICATION_FAILED: CertificateN
otMatched ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x80071C44
at System.Fabric.Interop.NativeClient.IFabricClusterManagementClient12.EndGetClusterManifest2(IFabricAsyncOperationContext context)
at System.Fabric.FabricClient.ClusterManagementClient.GetClusterManifestAsyncEndWrapper(IFabricAsyncOperationContext context)
at System.Fabric.Interop.AsyncCallOutAdapter2`1.Finish(IFabricAsyncOperationContext context, Boolean expectedCompletedSynchronously
)
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at SetupInfrastructure.ServiceFabricApplicationSetupManager`1.<GetImageStoreParameters>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at SetupInfrastructure.ServiceFabricApplicationSetupManager`1.<Deploy>d__24.MoveNext()<---
Press any key to exit
The key word I discovered is CertificateNotMatched, but I still don't know where exactly it's going wrong!
I also tried to Connect-ServiceFabricCluster using the new certServerThumbprint to the service fabric cluster and it give the following error
PS C:\Infrastructure\Scripts> ###### connect to the secure cluster using certs
$ClusterName= "xxx.xxx.xxx.xx.xx.xxxx:19000"
$CertThumbprint= "xxxxxxx"
Connect-serviceFabricCluster -ConnectionEndpoint $ClusterName -KeepAliveIntervalInSec 10 `
-X509Credential `
-ServerCertThumbprint $CertThumbprint `
-FindType FindByThumbprint `
-FindValue $CertThumbprint `
-StoreLocation CurrentUser `
-StoreName My
WARNING: Failed to contact Naming Service. Attempting to contact Failover Manager Service...
WARNING: Failed to contact Failover Manager Service, Attempting to contact FMM...
False
Connect-serviceFabricCluster : FABRIC_E_CONNECTION_DENIED: CertificateNotMatched
At line:4 char:1
+ Connect-serviceFabricCluster -ConnectionEndpoint $ClusterName -KeepAl ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Connect-ServiceFabricCluster], FabricConnectionDeniedException
+ FullyQualifiedErrorId : TestClusterConnectionErrorId,Microsoft.ServiceFabric.Powershell.ConnectCluster
Any help?