我已经部署了一个安全的服务结构集群,并且能够使用证书通过浏览器和PowerShell进行连接。从C#尝试相同的错误时:
执行期间发生错误
在 System.Fabric.Interop.Utility.WrapNativeSyncInvoke [TResult](Func`1 func,String functionTag,String functionArgs)at System.Fabric.Interop.Utility.RunInMTA(Action action)at System.Fabric.FabricClient.InitializeFabricClient(SecurityCredentials credentialArg,FabricClientSettings newSettings,String [] hostEndpointsArg)at CloseAppAPI.Controllers.CloseClientController.d__0.MoveNext() 在 C:\ Users \用户kumar.kshitij \源\回购\ CloseAPP \ CloseAppAPI \控制器\ CloseClientController.cs:线 39"
附加图像和代码以供参考。如果您有解决方案,请任何人通知我。
下面的C#代码: -
string CommonName = "www.cluster1.eastus2.cloudapp.azure.com";
string connection = "cluster1.eastus2.cloudapp.azure.com:19000";
var xc = GetCredentials(CommonName);
var fc = new FabricClient(xc, connection);
static X509Credentials GetCredentials(string clientCertThumb,
string serverCertThumb, string name)
{
X509Credentials xc = new X509Credentials();
xc.StoreLocation = StoreLocation.LocalMachine;
xc.StoreName = "Personal";
xc.FindType = X509FindType.FindByThumbprint;
xc.FindValue = "08DF81BD17507D4ADEC4DEE075E33A3CB8C8D04E";
xc.RemoteCommonNames.Add(name);
xc.RemoteCertThumbprints.Add("3D317C232F06AC1F5A2C8D16CC2830D6F7CD5FAC");
//xc.ProtectionLevel = ProtectionLevel.EncryptAndSign;
return xc;
}
答案 0 :(得分:0)
您在PowerShell中使用StoreLocation和StoreName的不同值。
尝试替换
xc.StoreName = "Personal";
xc.StoreLocation = StoreLocation.LocalMachine;
与
xc.StoreLocation = StoreLocation.CurrentUser;
xc.StoreName = "TrustedPeople";