Skip to content

Saml::Elements::KeyInfo.key_name being automatically generated #113

@lawliet89

Description

@lawliet89

In the initializer for Saml::Elements::KeyInfo, the key_name attribute is automatically generated.

When we try to do the following where the key defined in the IdP metadata has no ds:KeyName assigned:

saml_response = Saml::Response.new(...)
artifact_response = Saml::ArtifactResponse.new(status_value: Saml::TopLevelCodes::SUCCESS,
                                             issuer: 'https://idp.example.com',
                                             destination: 'https://sp.example.com/acs')
artifact_response.response = saml_response

artifact_resolution_url = Saml.provider( 'https://idp.example.com').artifact_resolution_service_url
stub_request(:post, artifact_resolution_url).to_return(body: Saml::Util.sign_xml(artifact_response, :soap))
request = ... # A mock request object with SAMLart set to some arbitrary value
Saml::Bindings::HTTPArtifact.resolve(request, artifact_resolution_url)

Then we will get a SignatureInvalid error. This is because in Saml::Provider.verify, it tries to find a key with the ID generated during the signing, but this key in the IdP metadata has no name and is thus not found. Thus the call certificate(key_name).public_key.verify(digest_method(signature_algorithm).new, signature, data) in Saml::Provider.verify fails because certificate(key_name) returns nil.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions