获取FABRIC_E_SERVER_AUTHENTICATION_FAILED:使用Service Fabric FabricClient获取CertificateNotMatched

时间:2016-04-16 21:30:29

标签: azure-service-fabric

以下控制台应用程序失败,异常

        static void Main(string[] args)
        {
            X509Credentials cert = new X509Credentials
            {
                FindType = X509FindType.FindByThumbprint,
                FindValue = "10A9BF925F41370FE55A4BDED2EF803505100C35",
                ProtectionLevel = ProtectionLevel.EncryptAndSign,
                StoreLocation = StoreLocation.CurrentUser,
                StoreName = "My",
            };

            var fabricClient = new FabricClient(cert,
                new FabricClientSettings
                {
                    ClientFriendlyName = "S-Innovations VSTS Deployment Client"
                }, "pksservicefabric11.westeurope.cloudapp.azure.com:19000");

            var a = fabricClient.QueryManager.GetApplicationListAsync().Result;

        }

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.Fabric.FabricServerAuthenticationFailedException: FABRIC_E_SERVER_AUTHENTICATION_FAILED: CertificateNotMatched ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x80071C44
   at System.Fabric.Interop.NativeClient.IFabricQueryClient7.EndGetApplicationList2(IFabricAsyncOperationContext context)
   at System.Fabric.FabricClient.QueryClient.GetApplicationListAsyncEndWrapper(IFabricAsyncOperationContext context)
   at System.Fabric.Interop.AsyncCallOutAdapter2`1.Finish(IFabricAsyncOperationContext context, Boolean expectedCompletedSynchronously)
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at DeployServiceFabricApplicationTask.Program.Main(String[] args) in C:\dev\sinnovations\MessageProcessor.ServiceFabric\vsts\DeployServiceFabricApplicationTask\Program.cs:line 32
Press any key to continue . . .

1 个答案:

答案 0 :(得分:2)

将指纹添加到RemoteCertThumbprints列表可以解决问题:

 X509Credentials cert = new X509Credentials       
 {
       FindType = X509FindType.FindByThumbprint,
       FindValue = "10A9BF925F41370FE55A4BDED2EF803505100C35",
       ProtectionLevel = ProtectionLevel.EncryptAndSign,
       StoreLocation = StoreLocation.CurrentUser,
       StoreName = "My",
 };
 cert.RemoteCertThumbprints.Add("10A9BF925F41370FE55A4BDED2EF803505100C35");