2016-04-16 30 views
1

下面的控制檯應用程序失敗,異常入門FABRIC_E_SERVER_AUTHENTICATION_FAILED:CertificateNotMatched與服務織物FabricClient

 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

添加指紋的RemoteCertThumbprints列表解決了這個問題:

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