Hi I have a requirement to validate the SAML Assertion XML Signature generated in Windows Identity Foundation (WIF) from the Perl script. I tried to implement this by loading the Assertion XML generated from WIF and calling verify on XML::Sig Perl module as shown below

$xml = XML::LibXML->load_from_file(..); my $signer = XML::Sig->new({ x509=>1 }); If($signer->verify($xml)) { } Eg Assertion XML from WIF: <Assertion ID="abc"> <bar>123</bar> <Signature xmlns="http://www.w3.org/2000/09/xmldsig#"> <SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#" xmlns:sam +lp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:xenc="http://www.w3.o +rg/2001/04/xmlenc#"> <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/R +EC-xml-c14n-20010315#WithComments" /> <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig# +rsa-sha1" /> <Reference URI="#abc"> <Transforms> <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#en +veloped-signature" /> </Transforms> <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#s +ha1" /> <DigestValue>9kpmrvv3peVJpNSTRycrV+jeHVY=</DigestValue> </Reference> </SignedInfo> <SignatureValue> HXUBnMgPJf//j4ihaWnaylNwAR5AzDFY83HljFIlLmTqX1w1C72ZTuRObvYve8 +TNEbVsQlTQkj4R hiY0pgIMQUb75GLYFtc+f0Y.......xwCdyGsIZOIZdQ8MWpeQrifxBR0d8W1Z +m6ix21WNv ONt575h7VxLKw8BDhNPS0p8CS3hOnSk29stpiDMCHFPxAwrbKVL1kGDLaLZn1q +8nNRmH8oFxG15l UmS3JXDZAss8gZhU7g9T4XllCqjrAvzPLOFdeQ== </SignatureValue> <KeyInfo> <X509Data><X509Certificate> MIICajCCAdOgAwIBAgIBADANBg.....00m0YZGyc4LzgD0CROMASTWNg==</X509Certif +icate></X509Data> </KeyInfo> </Signature> </Assertion>

WIF from windows is adding the pem content of the X509 Pub Certificate content to the X509Certificate tag. But when the above xml is loaded for signature verification XML::Sig throws an error "OpenSSL error: bad base64 decode". After going through the XML::Sig and Crypt::OpenSSL::RSA modules found that the expected value in X509Certificate is "RSA Public key”, it does not support X500 pem content.

So tried placing RSA public key within the X509 Certificate and called XML::Sig->verify , but the verify function never returned true. Can you please help me what am I missing here. Is the windows signed XML can be verified from Linux (Redhat 5.x)? Please share any hints/thoughts in getting the signature verification working in Perl. Thanks Sujatha


In reply to RSA lib called within XML::Sig fails to verify XML Signature genarated from windows by sujathagkn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.