1 adfs saml-2.0 asp.net-core-2.0 sustainsys-saml2
我有一个 .cer 文件,其中包含测试 AD FS 身份验证所需的公钥。我可以轻松地将其添加到解决方案中存在的 Web.config 的 MVC 示例中(设置signingCertificate fileName),它似乎可以工作,但我找不到任何方法来添加到 AspNetCore2 项目中。
我发现的最接近的是 SigningServiceCertificate,但它只有一个吸气剂,而且我在另一个线程中读到它应该以某种方式将公钥添加到 SigningKeys 集合中,我只是不知道如何实现。
谢谢你!
我不确定您到底在问什么,但我使用带有证书的 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;
}
Run Code Online (Sandbox Code Playgroud)
请注意,如果您在 Azure 中运行此程序,则还需要使用以下说明将指纹添加到应用程序设置 - https://learn.microsoft.com/en-us/azure/app-service/app-service-web- ssl 证书加载
您可以按照这些说明找到指纹 - https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-retrieve-the-thumbprint-of-a-certificate
| 归档时间: |
|
| 查看次数: |
2331 次 |
| 最近记录: |