4

I'm adding support for encrypted assertions to my SAML 2 IDP, and I'm trying to validate them against a number of SPs we work with. Everything looks good at https://www.samltool.com/online_tools.php (successfully validated encrypted assertions via the SAMLResponse validator tool) but things aren't working with Salesforce. And unlike most of the time, I can't get any useful debug info out of the SAML Assertion Validator. It doesn't record anything except the timestamp of failing assertions in history, and if I feed it a SAMLResponse directly, I get an internal server error. It asks me to contact support to provide more information, but that's not possible with a developer account. So I guess this is what I've got available.

  1. Everything works fine without encryption using the HTTP-POST binding. I can just disable encryption in my IDP, and Salesforce happily accepts the assertions.
  2. I am using a self-signed cert generated directly from the "Certificate and Key Management" page in the Salesforce setup, followed by downloading the certificate to add to the configuration in my IDP.
  3. I added that keypair as the "Assertion Decryption Certificate" in the "SAML Single Sign-On Settings" in Salesforce. I noted the change in the ACS URL and updated my IDP to match. And yes, it still accepts unencrypted assertions at the new ACS URL without problems.
  4. I'm using the IDP-initiated flow, sending SAMLResponses that don't correspond to any request.
  5. I'm not sending any RelayState.
  6. When salesforce receives the assertion, it displays the generic "Single Sign-On Error" page.
  7. When I check the SAML Assertion Validator, it shows me nothing about these failing requests in history - unless I also had a recent succeeding (unencrypted) request, in which case it shows me data from the succeeding request, except with the timestamp of the most recent failing request. This reads to me like it logged that a request happened, but not what the assertion it received was.
  8. If I paste the SAMLResponse (base64-encoded or not) into the input validator box on that page and hit the validate button, I get an internal server error.

Here's a sample of a failing SAMLResponse, still base64-encoded:

PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDphc3NlcnRpb24iIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIFZlcnNpb249IjIuMCIgSXNzdWVJbnN0YW50PSIyMDE5LTA1LTAzVDE2OjQwOjU0WiIgSUQ9Il8yNDMyZWI4Mi0xMDI4LTQ4ZjQtODY3MC1lNTU4N2FkYTJiMGYiIERlc3RpbmF0aW9u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bDczMWdTdkZKNWV0cG11V0ZOTmYrdm9QSm5aVnY0WU81aVhHRDM1NGhTNVo3YkdZVjFOa01yaFFiMjdMeEtlTE1zNUNFc0o2UXdJbXlsLzVsblQzMVNuN0JpTDJwdnREWkdmUS9md05mcXNXb3ZhR2gxMjExTWZkQ2MzWDdXVkxLOEVsZzJTL09RUkNwNGlZRm5WY3g3UzRzM2FBU3c0ejg3MFNxNjlxYWtPZllOY2V5Z2s5ajRLQTQ5T3lFYm9LcFc5R1ZRZG4zY3hTcnFBUFFRd0RES3QxcEVoTVFLT0JGL2dMWHY3V2cwQzhoSWlUdG9vaFdONk1EbDMraGlVN09oVHBhRUY2Z0Vvb3JCYU9rUGNqbmpsU3Q0THFiRTVZcG5CYVloTmpRZVIzQT09PC9DaXBoZXJWYWx1ZT48L0NpcGhlckRhdGE+PC9FbmNyeXB0ZWREYXRhPjwvc2FtbDpFbmNyeXB0ZWRBc3NlcnRpb24+PC9zYW1scDpSZXNwb25zZT4K

Here's the same SAMLResponse decoded and pretty-printed for readability. Once again, this has been pretty-printed for readability. The actual bytes sent are the base64-encoded version above.

<?xml version="1.0"?>
<samlp:Response xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Version="2.0" IssueInstant="2019-05-03T16:40:54Z" ID="_2432eb82-1028-48f4-8670-e5587ada2b0f" Destination="https://login.salesforce.com?so=00D2E000001Fx1x&amp;sc=0LE2E000000TfPW">
  <saml:Issuer>http://localhost:3000/saml/efd994bb-b796-488b-ac01-2e2beee79f1f/metadata</saml:Issuer>
  <samlp:Status>
    <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
  </samlp:Status>
  <saml:EncryptedAssertion>
    <EncryptedData xmlns="http://www.w3.org/2001/04/xmlenc#">
      <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/>
      <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
        <EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#" Id="_b10698ab-d506-44d1-adc2-f22bcb3647b6">
          <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"/>
          <CipherData>
            <CipherValue>aCH9yNjxFWczLWtYkNiLSmTGiD9OV9oqjk9KoA0TQF1kW0SYsTpCpjOVGynZ83CqdYalWByANZqjwVY8G6iGPUUXpL1tTGU3xaNYIfmKNxL3fQ8gieF6MDz6GPLNLPv4yW/ZklLaDiGatgaLI+lkKDu8QBLzAsmTeftaF+RTpgeiIi5NNynf4VPW8v0jGdv+B4xj2YkAjGoIH8YTKMlclLEISRDi9P1mhqwdKi9dOYKGLExUO+t+rRN60OYxJkCZybEZ80DFagv3RDraLsgFbwc3NOBlBjcWI1w5gp+FOeJyVp5QQS63DltnLFGh0a7Vr2BvctbCq1OYuDqitvzeaA==</CipherValue>
          </CipherData>
        </EncryptedKey>
      </KeyInfo>
      <CipherData>
        <CipherValue>AKh0LEWi++F3Ua8Wbfdm7VhqYhjyhHD0saHVVd0MDC7044RAVi45rKh0kvEeBmyCx+ehgprfe906L+Jdn1Or1pQLrnYah9yC3NVTRKd4X9Pavc1bT/igGWvPqnLj0TIG3XNatYlui/LH9dhIA4R2jx4Df+Nxw5ttoO3AijWUiRtti2je4ff4Za9ugVO+Ka2WjlOFjiLwp+2CQaLdD0E8/OYkRkDvp9B4K7cqDHFB3rcAz44+AztKSVxOtePWkpVPKvcjiBDhuBs8Ghx3eqwRQ+kIY0pIdM7sxbAlaMUG7te+sCuiNee9Ujqd3pTv02xGaX4OYXmxBiQ2WksYMAGVNtiKTZ4GbWIm3q53WUX/lG/E3FgOhuGVRZNaWAeKPMMT0NH/+jjVbmU11w/FY1LkkuS6ITelA/HqrJ2SmMVic6ty12EWdvF/HBA/XNuNs0NZDS2V6M6AONnT1yvCWvNLlJodm4dRI966hR2J3bisMddTFQPAl3X1WmYz2AFiXx0KC2GSEOX/kPmEtYNkdgPzPRV9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n3uXtC2hv+o+rZOVvGS7tlfPm0ncu8hO2WAzrc01EWecaTMozOn9iVLfejEeYsrlkUjmmWocRqIyizmPGPuKH5ma3UTEk5jsCqqWi62spLmXa8wFRF50I1LLVY/d4ObsN0Nf/vpCS9w9ZAG0pAHCLDLigQVcWNxbqXUjq7krzhsFptrFLs3DKpwNn33Tlr6x9ICjx8ACLj96lLaoZTvCaNiPKlsqRpqzF+LazuSwadIngmdxN5M85510DVubmgyJxvo07Uge/ekMYBNVwtZtuwMO/HZImHHZsfZ0qqKQo8csTUV4/BicxJolwb3WpoEu6uF/Q5i0gD/xqqLZQnFU+R0lRrhMehqtykmokeN5C2L96JVgasOTnSsbwjDaOBjeir+ABSmmAHtb+w0pqmy/T3cH1rkoTQtVvSk32bSLScRQN+yVYQDeF8CJer9Gm3X5TOJRXyXwCawI+JK+xUdoSk7IGw7VdobnMLeW9GcOa+mNEAqMcbKk/HqI+pPKdLsRw9mqnvxq9cp4S4CTumxK9IC2scRyqijaDYdv5qfG/tSEhPKk8WvEDMguM5bFWT5zFzntWEGX8HKEXj67Di+OYdKnID3Gpjrn/qdxTSzAh7ZHh05/+F0Gu+acbxSmr70bMIIlo1oyKeZ8MDxQny+UuIEmvefuZ3GAT3mz2zfyhMKiacil731gSvFJ5etpmuWFNNf+voPJnZVv4YO5iXGD354hS5Z7bGYV1NkMrhQb27LxKeLMs5CEsJ6QwImyl/5lnT31Sn7BiL2pvtDZGfQ/fwNfqsWovaGh1211MfdCc3X7WVLK8Elg2S/OQRCp4iYFnVcx7S4s3aASw4z870Sq69qakOfYNceygk9j4KA49OyEboKpW9GVQdn3cxSrqAPQQwDDKt1pEhMQKOBF/gLXv7Wg0C8hIiTtoohWN6MDl3+hiU7OhTpaEF6gEoorBaOkPcjnjlSt4LqbE5YpnBaYhNjQeR3A==</CipherValue>
      </CipherData>
    </EncryptedData>
  </saml:EncryptedAssertion>
</samlp:Response>

Given that the encrypted assertions I generate are accepted by the samltool.com online validator (and I've done a test decrypt myself, everything looked right), I'm guessing that the problem is in the KeyInfo section. I'm guessing Salesforce wants some indicator what certificate was used to encrypt the assertion, and is blowing up without it, even though the config explicitly says what keypair to use to decrypt encrypted assertions.

Whether that's right or not, I'm clearly missing something salesforce is expecting to be present in an EncryptedAssertion. (Just because it's valid by the schema doesn't mean it'll be accepted, of course. But crashing the validator tool gives me almost nothing to work with to fix the problem.)

Is there any way I can get in touch with a Salesforce technical person to report the internal server errors and nudge them to upgrade their SAML assertion validator so that it reports useful information instead of crashing in this case?

And more directly, does anyone either know what the problem is, or have an example of an encrypted assertion that Salesforce accepts that I can base further experiments on?

1

There are examples of encrypted assertions Salesforce wants as an SP in https://help.salesforce.com/articleView?id=sso_saml_assertion_examples.htm&type=5

When I try your response with SAML Validator in my Dev Ed org, it doesn't blow up. I get the expected "Unable to parse the response" with "Data encryption key may not be null" as a more specific error message. The latter message makes sense - it doesn't know how to resolve the wrapped key since I don't have your keypair and SAML Validator doesn't know what IdP config/metadata to use.

Here's the encrypted response that Salesforce emits as an IdP


<?xml version="1.0"?>
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Destination="..." ID="_29ae1f1f3533f532b16dd6441226baa91557114849567" IssueInstant="2019-05-06T03:54:09.567Z" Version="2.0">
  <saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">https://blah.my.salesforce.com</saml:Issuer>
  <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
    <ds:SignedInfo>
      <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
      <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
      <ds:Reference URI="#_29ae1f1f3533f532b16dd6441226baa91557114849567">
        <ds:Transforms>
          <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
          <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
            <ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="ds saml samlp xenc"/>
          </ds:Transform>
        </ds:Transforms>
        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
        <ds:DigestValue>N3EWufNWXbpY1NDWRk8M4sfv+NM=</ds:DigestValue>
      </ds:Reference>
    </ds:SignedInfo>
    <ds:SignatureValue>...</ds:SignatureValue>
    <ds:KeyInfo>
      <ds:X509Data>
        <ds:X509Certificate>....</ds:X509Certificate>
      </ds:X509Data>
    </ds:KeyInfo>
  </ds:Signature>
  <samlp:Status>
    <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
  </samlp:Status>
  <saml:EncryptedAssertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
    <xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="_6abe53cbeed22854b456ced0867305f2" Type="http://www.w3.org/2001/04/xmlenc#Element">
      <xenc:EncryptionMethod xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/>
      <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <ds:RetrievalMethod Type="http://www.w3.org/2001/04/xmlenc#EncryptedKey" URI="#_87fcbe553f29ac429e5133904115d774"/>
      </ds:KeyInfo>
      <xenc:CipherData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
        <xenc:CipherValue>...</xenc:CipherValue>
      </xenc:CipherData>
    </xenc:EncryptedData>
    <xenc:EncryptedKey xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="_87fcbe553f29ac429e5133904115d774">
      <xenc:EncryptionMethod xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
        <ds:DigestMethod xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
      </xenc:EncryptionMethod>
      <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <ds:KeyValue>
          <ds:RSAKeyValue>
            <ds:Modulus>...</ds:Modulus>
            <ds:Exponent>AQAB</ds:Exponent>
          </ds:RSAKeyValue>
        </ds:KeyValue>
      </ds:KeyInfo>
      <xenc:CipherData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
        <xenc:CipherValue>...</xenc:CipherValue>
      </xenc:CipherData>
      <xenc:ReferenceList>
        <xenc:DataReference URI="#_6abe53cbeed22854b456ced0867305f2"/>
      </xenc:ReferenceList>
    </xenc:EncryptedKey>
  </saml:EncryptedAssertion>
</samlp:Response>

Note the decryption key (EncryptedKey element) alongside rather than within the encrypted data (EncryptedData element) and the public key embedded inside the decryption key. From a spec perspective having decryption key inside EncryptedData as shown in your example is also valid and there should be no need to transmit the public key...but if you can change your response to mimic SF IdP, it might be worth a shot.

If you can't get it to work, post your question to Salesforce Identity group on SF-managed communities:

https://success.salesforce.com/_ui/core/chatter/groups/GroupProfilePage?g=0F9300000001q1N

  • Restructured the EncryptedAssertion, no change in behavior. But I think your pointer to the Salesforce Identity group is going to pay off. – Carl May 9 at 0:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.