我有一个安全的服务结构集群。相同的证书用作服务器证书和客户端身份验证。我无法创建FabricClient
在控制台应用程序中,它允许我连接到该集群。我正在使用记录的代码片段here https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-connect-to-secure-cluster在“使用客户端证书连接到安全集群”下:
static void Main(string[] args)
{
string thumb = "1234567890123456789012345678901234567890";
string CommonName = "somefabric.cloudapp.azure.com";
string connection = "somefabric.cloudapp.azure.com:19000";
try
{
X509Credentials xc = GetCredentials(thumb, thumb, CommonName);
FabricClient fc = new FabricClient(xc, connection);
Console.WriteLine("Cluster is connected");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.ReadKey();
}
static X509Credentials GetCredentials(string clientCertThumb, string serverCertThumb, string name)
{
X509Credentials xc = new X509Credentials();
// Client certificate
xc.StoreLocation = StoreLocation.CurrentUser;
xc.StoreName = "MY";
xc.FindType = X509FindType.FindByThumbprint;
xc.FindValue = clientCertThumb;
// Server certificate
xc.RemoteCertThumbprints.Add(serverCertThumb);
xc.RemoteCommonNames.Add(name);
xc.ProtectionLevel = ProtectionLevel.EncryptAndSign;
return xc;
}
这段代码的结果是
指定的 X509 指纹无效。
看来该证书确实授予我通过其他方式访问的权限。我能够成功查看 Fabric Explorer 并
以下 PowerShell 命令也成功连接到集群
Connect-ServiceFabricCluster
-ConnectionEndpoint somefabric.cloudapp.azure.com:19000
-X509Credential
-FindType FindByThumbprint
-FindValue 1234567890123456789012345678901234567890
-StoreLocation CurrentUser
-StoreName MY
-ServerCertThumbprint 1234567890123456789012345678901234567890
我在这里做错了什么?
我遇到了这个确切的问题,但原因却截然不同。
我对此感到困惑;
- https 资源管理器有效(在 IExporer 中)
- Powershell Connect-ServiceFabricCluster 也有效。
- Visual Studio 发布失败
我发现我的指纹值后面附加了 4 个不可见的字符,这可能是剪切和粘贴操作造成的。怎么,为什么?不知道
我只是在编辑 Deploy-FabricApplication 添加此行后才发现这一点。
$publishProfile.ClusterConnectionParameters|Format-List
就在之前
[void](Connect-ServiceFabricCluster @ClusterConnectionParameters)
然后我看到看不见的字符显示为???在指纹的末尾。
使用二进制编辑器打开 Cloud.xml 文件可以让我查看它们并删除它们。
然后我就可以发布我的申请了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)