英文:
I am trying to use ITfoxtec to send metadata to the IdP but I get an obscure error
问题
I am using ITfoxtec SAML library in a .Net Core web app that will be a service provider and it will be connecting to a SAML identity provider to initiate single-sign on.
我正在使用 ITfoxtec SAML 库在一个 .Net Core web 应用程序中,该应用程序将作为服务提供商,连接到 SAML 身份提供商以启动单点登录。
I am trying to setup my SP metadata that the IdP needs.
我正在尝试设置我的服务提供商元数据,这是身份提供商所需的。
Whenever I run the web app and try to test if it's working, it starts up fine, and I try to sign in via single sign on, I get this error:
每当我运行 web 应用程序并尝试测试其是否正常工作时,它都会启动正常,但当我尝试通过单点登录登录时,我会收到以下错误消息:
“Signature is invalid”
“签名无效”
I have the following in my appsettings.json file:
我在我的 appsettings.json 文件中有以下内容:
"Saml2": {
"IdPMetadata": "https://zion.xyz.edu/idp",
"Issuer": "Arizona State",
"SignatureAlgorithm": "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",
"SigningCertificateFile": "itfoxtec.identity.saml2.testwebappcore_Certificate.pfx",
"SigningCertificatePassword": "!QAZ2wsx",
"CertificateValidationMode": "None",
"RevocationMode": "NoCheck",
"samlMetadataUrl": "~/SP_webapp/Metadata"
}
That samlMetadataUrl
is supposed to point to my MetadatController.cs which has this code:
samlMetadataUrl
应该指向我的 MetadatController.cs,其中包含以下代码:
public class MetadataController : Controller
{
private readonly Saml2Configuration config;
public MetadataController(IOptions<Saml2Configuration> configAccessor)
{
config = configAccessor.Value;
}
// ... (其他代码)
return new Saml2Metadata(entityDescriptor).CreateMetadata().ToActionResult();
}
// ... (其他代码)
Is there anything specific you would like to know or do related to this code?
英文:
I am using ITfoxtec SAML library in a .Net Core web app that will be a service provider and it will be connecting to a SAML identity provider to initiate single-sign on.
I am trying to setup my SP metadata that the IdP needs.
Whenever I run the web app and try to test if it's working, it starts up fine, and I try to sign in via single sign on, I get this error:
> “Signature is invalid”
I have the following in my appsettings.json file:
"Saml2": {
"IdPMetadata": "https://zion.xyz.edu/idp ",
"Issuer": "Arizona State",
"SignatureAlgorithm": "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",
"SigningCertificateFile": "itfoxtec.identity.saml2.testwebappcore_Certificate.pfx",
"SigningCertificatePassword": "!QAZ2wsx",
"CertificateValidationMode": "None",
"RevocationMode": "NoCheck",
"samlMetadataUrl": "~/SP_webapp/Metadata"
}
That samlMetadataUrl
is supposed to point to my MetadatController.cs which has this code:
public class MetadataController : Controller
{
private readonly Saml2Configuration config;
public MetadataController(IOptions<Saml2Configuration> configAccessor)
{
config = configAccessor.Value;
}
public IActionResult Index()
{
var defaultSite = new Uri($"{Request.Scheme}://{Request.Host.ToUriComponent()}/");
var entityDescriptor = new EntityDescriptor(config);
entityDescriptor.ValidUntil = 365;
entityDescriptor.SPSsoDescriptor = new SPSsoDescriptor
{
WantAssertionsSigned = true,
SigningCertificates = new X509Certificate2[]
{
config.SigningCertificate
},
//EncryptionCertificates = new X509Certificate2[]
//{
// config.DecryptionCertificate
//},
SingleLogoutServices = new SingleLogoutService[]
{
new SingleLogoutService { Binding = ProtocolBindings.HttpPost, Location = new Uri(defaultSite, "Auth/SingleLogout"), ResponseLocation = new Uri(defaultSite, "Auth/LoggedOut") }
},
NameIDFormats = new Uri[] { NameIdentifierFormats.X509SubjectName },
AssertionConsumerServices = new AssertionConsumerService[]
{
new AssertionConsumerService { Binding = ProtocolBindings.HttpPost, Location = new Uri(defaultSite, "Auth/AssertionConsumerService") },
},
AttributeConsumingServices = new AttributeConsumingService[]
{
new AttributeConsumingService { ServiceName = new ServiceName("Some SP", "en"), RequestedAttributes = CreateRequestedAttributes() }
},
};
entityDescriptor.ContactPersons = new[] {
new ContactPerson(ContactTypes.Administrative)
{
Company = "Arizona State",
GivenName = "Redding",
SurName = "Smith",
EmailAddress = "rs23@123.edu",
TelephoneNumber = "xxx-214-3932",
}
//}
};
return new Saml2Metadata(entityDescriptor).CreateMetadata().ToActionResult();
}
private IEnumerable<RequestedAttribute> CreateRequestedAttributes()
{
yield return new RequestedAttribute("urn:oid:2.5.4.4");
yield return new RequestedAttribute("urn:oid:2.5.4.3", false);
yield return new RequestedAttribute("urn:xxx", true, "test-value");
}
}
答案1
得分: 1
如果在调用IdP时出现错误,要求SAML身份验证进行签名,那么IdP的SP元数据可能不正确。
如果用户在IdP上登录后出现错误,那么IdP元数据中的"IdPMetadata": "https://zion.xyz.edu/idp"
,包含IdP证书的部分可能不正确。还有可能是IdP使用了其他签名算法,"SignatureAlgorithm": "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
。
英文:
If you get the error on the IdP when it is called you are requring the SAML Authn to be signed, the the IdP has an incorrect SP metadata.
If you get the error after the user has logged in at the IdP the IdP metadata "IdPMetadata": "https://zion.xyz.edu/idp"
containing the IdP certificate is incorrect. It is also possible that the IdP use another signature algorithm "SignatureAlgorithm": "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论