Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for namespace prefixes, X509 handling etc #1

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

chrisa
Copy link

@chrisa chrisa commented Oct 4, 2010

Hi,

Here's a few changes to XML::Sig which fix the problems I found trying to deal with SAML messages signed with X509 certificates:

  • Handle the XML signature elements having a namespace prefix
  • Emit signature elements with a namespace prefix
  • Fix the X509 certificate handling
  • Expose the signing certificate after a successful verify, for validation
  • Fix a couple of canonicalization bugs

These changes fix the "TODO" test in t/006_signing.t, and add a number of other tests. All the existing tests still pass.

I'd appreciate it if you could take a look at these changes.

Thanks,
Chris.

Chris Andrews added 11 commits October 4, 2010 11:24
When transforming the XML document during verification, the method calls
implementing canonicalization were misspelled, so attempts to verify
documents specifying the canonicalization transforms would fail.
The contents of the <X509Certificate> element were being treated as
a PEM public key, rather than as a PEM certificate. This change uses
Crypt::OpenSSL::X509 to convert the certificate to a public key, which
permits use of this module to verify such documents.
This adds support for documents with namespaces such as SAML assertions.
This module was stripping the namespace prefixes from the document as
part of canonicalization, which means that verification would always
fail.
This test shows that the module can be used to verify the signature
on a SAML assertion using an X509 certificate.
The module was embedding a PEM-formatted public key as the value of
the <X509Certificate> element, rather than the certificate. The
public key was derived from the private key, so this change adds a
new "cert" option to allow the corresponding certificate to be provided.

This change permits the TODO in t/006_signing.t to be removed as the
test now passes in its entirety.
When a document with an embedded X509 certificate has been
successfully verified, the certificate will be available for
verification. The certificate is returned as a Crypt::OpenSSL::X509
object.
This shows that we can successfully sign and then verify a SAML
request using an X509 certificate.
The transform requested, http://www.w3.org/2001/10/xml-exc-c14n#,
requests exclusive canonicalization - make sure that's what we apply.
We now use namespace prefixes when signing, on the elements we add
to the document.
We canonicalize before signing, so we need to add that transform
to the set in our SignedInfo. This causes the verify operation to
also canonicalize.

Update the signing test to show that even if the document to be
signed is not already in canonical form we can successfully round-
trip it.
This allows verifying signed documents where the certificate
value is not included.
timlegge referenced this pull request in timlegge/perl-XML-Sig-old Jun 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant