我不确定您到底在问什么,但是我使用带有证书的 Sustainsys,并且使用以下行:
var idp = new Sustainsys.Saml2.IdentityProvider(new entityId("https://sso.acme.com"), opt.SPOptions) { ... insert properties ... }
idp.SigningKeys.AddConfiguredKey(new X509Certificate2("customer-certificate.cer"));
opt.SPOptions.ServiceCertificates.Add(EncryptionHelper.GetX509Certificate2("INSERT-THUMBPRINT-OF-YOUR-CERTIFICATE"));
EncryptionHelper.GetX509Certificate2
我为阅读我的证书而编写的自定义助手在哪里。
这是代码EncryptionHelper
- 我在网上众多示例之一的背面制作了它。
public static X509Certificate2 GetX509Certificate2(string thumbprint)
{
X509Certificate2 retVal = null;
var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
var certCollection = store.Certificates;
var signingCert = certCollection.Find(X509FindType.FindByThumbprint, thumbprint, false);
if (signingCert.Count > 0)
{
retVal = signingCert[0];
}
return retVal;
}
请注意,如果您在 Azure 中运行它,那么您还需要使用这些说明将指纹添加到应用程序设置 - https://docs.microsoft.com/en-us/azure/app-service/app-service-web- ssl 证书加载
您可以按照这些说明找到指纹 - https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-retrieve-the-thumbprint-of-a-certificate