ApplicationOverride results in "Unable to locate an encrypted key"

Cameron Kerr cameron.kerr at otago.ac.nz
Wed Nov 2 07:43:45 EDT 2016


I am in the processing of building a new Shibboleth IdP (v3.2.1) to replace our existing v2.x IdP, and have struck an error when using ApplicationOverride. The browser reports the following when coming back from the IdP

    opensaml::FatalProfileException at (https://siteA.192.168.33.10.xip.io/Shibboleth.sso/SAML2/POST)

    A valid authentication statement was not found in the incoming message.


I have built a test VM to run a Shibboleth native SP (shibboleth-2.6.0-2.1.x86_64) with httpd to recreate a similar environment to one we already use successfully with our old IdP. This SP environment makes use of application overrides (host-based). The existing SP uses the same version of the Shibboleth SP, on RHEL6.

I have built this test  SP using Vagrant with CentOS 7. Because I’m doing this in Vagrant, I’ve used xip.io to create DNS names. For those not familiar with xip.io, it’s a DNS service that turns a DNS name such as 1.2.3.4.xip.io into the IP address 1.2.3.4 (and similarly foo.1.2.3.4.xip.io also renders the IP address 1.2.3.4)

So my SP has two entityIDs:

  - https://192.168.33.10.xip.io/shibboleth    (this is the default entityID of the SP)
  - https://siteA.192.168.33.10.xip.io/shibboleth   (this is the ‘siteA’ application override)

The default SP is working fine; it’s just siteA that fails when returning from the IdP.

Here are the SP logs for the BROKEN case (https://sitea.192.168.33.10.xip.io/secure) 

 …
 DEBUG OpenSAML.MessageDecoder.SAML2 [2]: extracting issuer from SAML 2.0 protocol message
 DEBUG OpenSAML.MessageDecoder.SAML2 [2]: message from (https://idp-test.otago.ac.nz/idp/shibboleth)
 DEBUG OpenSAML.MessageDecoder.SAML2 [2]: searching metadata for message issuer...
 DEBUG OpenSAML.SecurityPolicyRule.MessageFlow [2]: evaluating message flow policy (replay checking on, expiration 60)
 DEBUG XMLTooling.StorageService [2]: inserted record (_158290de19d9735d17f0bc8a3afb7cb9) in context (MessageFlow) with expiration (1478053302)
 DEBUG OpenSAML.SecurityPolicyRule.XMLSigning [2]: validating signature profile
 DEBUG XMLTooling.CredentialCriteria [2]: keys didn't match
 DEBUG XMLTooling.TrustEngine.ExplicitKey [2]: attempting to validate signature with the peer's credentials
 DEBUG XMLTooling.TrustEngine.ExplicitKey [2]: signature validated with credential
 DEBUG OpenSAML.SecurityPolicyRule.XMLSigning [2]: signature verified against message issuer
 DEBUG Shibboleth.SSO.SAML2 [2]: processing message against SAML 2.0 SSO profile
 DEBUG XMLTooling.KeyInfoResolver.Inline [2]: resolved 0 certificate(s)
 DEBUG XMLTooling.CredentialCriteria [2]: key algorithm didn't match ('AES' != 'RSA')
 ERROR Shibboleth.SSO.SAML2 [2]: failed to decrypt assertion: Unable to locate an encrypted key.     <<<<< DEVIATES

Compare that with the WORKING case (https://192.168.33.10.xip.io/secure) and you see it deviates only at the second-to-last line where I’ve marked it.

 …		
 DEBUG OpenSAML.MessageDecoder.SAML2 [3]: extracting issuer from SAML 2.0 protocol message
 DEBUG OpenSAML.MessageDecoder.SAML2 [3]: message from (https://idp-test.otago.ac.nz/idp/shibboleth)
 DEBUG OpenSAML.MessageDecoder.SAML2 [3]: searching metadata for message issuer...
 DEBUG OpenSAML.SecurityPolicyRule.MessageFlow [3]: evaluating message flow policy (replay checking on, expiration 60)
 DEBUG XMLTooling.StorageService [3]: inserted record (_f9b58700bdec49eceab030eaa6ccccec) in context (MessageFlow) with expiration (1478053004)
 DEBUG OpenSAML.SecurityPolicyRule.XMLSigning [3]: validating signature profile
 DEBUG XMLTooling.CredentialCriteria [3]: keys didn't match
 DEBUG XMLTooling.TrustEngine.ExplicitKey [3]: attempting to validate signature with the peer's credentials
 DEBUG XMLTooling.TrustEngine.ExplicitKey [3]: signature validated with credential
 DEBUG OpenSAML.SecurityPolicyRule.XMLSigning [3]: signature verified against message issuer
 DEBUG Shibboleth.SSO.SAML2 [3]: processing message against SAML 2.0 SSO profile
 DEBUG XMLTooling.KeyInfoResolver.Inline [3]: resolved 0 certificate(s)
 DEBUG XMLTooling.CredentialCriteria [3]: key algorithm didn't match ('AES' != 'RSA')
 DEBUG XMLTooling.KeyInfoResolver.Inline [3]: resolving ds:X509Certificate                <<<<< DEVIATES
 DEBUG XMLTooling.KeyInfoResolver.Inline [3]: resolved 1 certificate(s)



I had originally create the SP certificate manually, adding DNS:siteA.192.168.33.10.xip.io as an alternate name, but in troubleshooting I saw that you can have a different certificate per application override, so I did that instead, creating /etc/shibboleth/creds.{default,siteA}/sp-{cert,key}.pem using the provided ./keygen.sh script.

Here’s the part of shibboleth2.xml that uses it. Having seen similar issues on this mailing list, I tried extractnames="false" and extractnames="true", with no change in result.

    <ApplicationDefaults entityID="https://192.168.33.10.xip.io/shibboleth"
                         REMOTE_USER="Shib-Attr-uid">
        ...
        <CredentialResolver type="File" key="creds.default/sp-key.pem" certificate="creds.default/sp-cert.pem"/>
        ...
        <ApplicationOverride id="siteA" entityID="https://siteA.192.168.33.10.xip.io/shibboleth">
            <CredentialResolver type="File"
                         certificate="creds.siteA/sp-cert.pem"
                                 key="creds.siteA/sp-key.pem"/>
        </ApplicationOverride>
    </ApplicationDefaults>

I then harvested the metadata from https://siteA.192.168.33.10.xip.io/Shibboleth.sso/Metadata, saving to to /etc/shibboleth/creds.siteA/sp-metadata.xml (just for reference). Remembering that the metadata generator doesn’t take account of application overrides, I edited the file, changing the certificates and entity ID to match. I similarly harvested the metadata for the ‘default’ application override; naturally, it seemed more useful.

Here is the complete siteA metadata:

<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" ID="_b6b353605e6d62f7b900563ea350769971736a84" entityID="https://siteA.192.168.33.10.xip.io/shibboleth">

  <md:Extensions xmlns:alg="urn:oasis:names:tc:SAML:metadata:algsupport">
    <alg:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha512"/>
    <alg:DigestMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#sha384"/>
    <alg:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
    <alg:DigestMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#sha224"/>
    <alg:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
    <alg:SigningMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512"/>
    <alg:SigningMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384"/>
    <alg:SigningMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256"/>
    <alg:SigningMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha224"/>
    <alg:SigningMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"/>
    <alg:SigningMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha384"/>
    <alg:SigningMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
    <alg:SigningMethod Algorithm="http://www.w3.org/2009/xmldsig11#dsa-sha256"/>
    <alg:SigningMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1"/>
    <alg:SigningMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
    <alg:SigningMethod Algorithm="http://www.w3.org/2000/09/xmldsig#dsa-sha1"/>
  </md:Extensions>

  <md:SPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
    <md:Extensions>
      <init:RequestInitiator xmlns:init="urn:oasis:names:tc:SAML:profiles:SSO:request-init" Binding="urn:oasis:names:tc:SAML:profiles:SSO:request-init" Location="https://siteA.192.168.33.10.xip.io/Shibboleth.sso/Login"/>
    </md:Extensions>
    <md:KeyDescriptor>
      <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <ds:KeyName>siteA.192.168.33.10.xip.io</ds:KeyName>
        <ds:KeyName>https://siteA.192.168.33.10.xip.io/shibboleth</ds:KeyName>
        <ds:X509Data>
          <ds:X509SubjectName>CN=siteA.192.168.33.10.xip.io</ds:X509SubjectName>
          <ds:X509Certificate>MIIERDCCAqygAwIBAgIJAM4D4MPTljdOMA0GCSqGSIb3DQEBCwUAMCUxIzAhBgNV
BAMTGnNpd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7epR+4ezj2Uk9i5SON4LOt59Dvp5Rk3
BePAnGNYQrRZaAPmfq2I77fsI2Ok3tgFkom8N8fw+phf95x4OAZKpD4K137RhIaQ
b9NkFxeqHCTTx/WTVxt/4urUYohMyA5tUZ4Ay59plPQyM3OVW/1AFFKaWQKSupx4
Uin0A0t1xE1Zkcgnhu1nVe25EdNwGncHKC9w9WqCdzS7ElEazO3js2kK2oNQfa3x
1O+dbkAcXLNOLFmBdyJgyBKJbMhRkLQT9v4TQ0223rR8cLifS/wa1UU6EuISd3jb
rzeiVNvcvGs3SIGvKy/OcQCDacPj97sszh+epINBVHXrXMarbauLwQ==
</ds:X509Certificate>
        </ds:X509Data>
      </ds:KeyInfo>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2009/xmlenc11#aes128-gcm"/>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2009/xmlenc11#aes192-gcm"/>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2009/xmlenc11#aes256-gcm"/>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes192-cbc"/>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2009/xmlenc11#rsa-oaep"/>
      <md:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"/>
    </md:KeyDescriptor>
    <md:ArtifactResolutionService Binding="urn:oasis:names:tc:SAML:2.0:bindings:SOAP" Location="https://siteA.192.168.33.10.xip.io/Shibboleth.sso/Artifact/SOAP" index="1"/>
    <md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:SOAP" Location="https://siteA.192.168.33.10.xip.io/Shibboleth.sso/SLO/SOAP"/>
    <md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="https://siteA.192.168.33.10.xip.io/Shibboleth.sso/SLO/Redirect"/>
    <md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://siteA.192.168.33.10.xip.io/Shibboleth.sso/SLO/POST"/>
    <md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact" Location="https://siteA.192.168.33.10.xip.io/Shibboleth.sso/SLO/Artifact"/>
    <md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://siteA.192.168.33.10.xip.io/Shibboleth.sso/SAML2/POST" index="1"/>
    <md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST-SimpleSign" Location="https://siteA.192.168.33.10.xip.io/Shibboleth.sso/SAML2/POST-SimpleSign" index="2"/>
    <md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact" Location="https://siteA.192.168.33.10.xip.io/Shibboleth.sso/SAML2/Artifact" index="3"/>
    <md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:PAOS" Location="https://siteA.192.168.33.10.xip.io/Shibboleth.sso/SAML2/ECP" index="4"/>
  </md:SPSSODescriptor>
</md:EntityDescriptor>


The contents of the certificate in the metadata, when decorating and running through 'openssl x509 -text -noout' follow. You can see that it has the correct name and altnames.

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 14844955928416368462 (0xce03e0c3d396374e)
    Signature Algorithm: sha256WithRSAEncryption
        Issuer: CN=siteA.192.168.33.10.xip.io
        Validity
            Not Before: Nov  2 03:53:17 2016 GMT
            Not After : Oct 31 03:53:17 2026 GMT
        Subject: CN=siteA.192.168.33.10.xip.io
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (3072 bit)
                Modulus:
                    00:bc:bd:56:aa:3b:27:db:e6:bf:13:e2:33:c8:7d:
                    93:63:be:9f:bd:d5:03:64:9f:c8:0e:07:80:45:29:
                    4a:0c:70:97:62:1d:1e:7d:38:ea:bb:1d:4d:e7:82:
                    4e:0c:6d:4d:42:df:3a:da:d8:c0:e5:ab:3e:66:83:
                    9c:b4:b8:7f:16:d9:c6:fb:b4:73:6b:ac:f9:9c:16:
                    c1:a0:b4:85:83:85:f8:47:f6:c3:5f:26:ae:1f:ad:
                    ae:86:2b:cb:f8:30:2d:b1:c5:4b:66:fb:32:e7:38:
                    95:ce:26:2a:e4:4a:bb:01:7d:ce:4c:98:97:3c:f4:
                    dd:85:b9:1e:9e:21:5b:b5:99:17:57:cd:38:68:bf:
                    57:b7:9f:06:c7:98:f7:77:00:e6:da:e2:fc:d0:9a:
                    11:47:f2:9d:c2:18:48:de:bd:b4:76:77:4f:0d:44:
                    34:fd:2c:99:1c:b7:82:2a:c7:8d:6c:d5:40:03:8e:
                    ea:61:dc:6a:32:30:a8:78:ef:3b:35:d1:5e:ac:d6:
                    fd:b4:13:c0:b9:b8:b4:0a:4a:48:7b:85:7c:fc:bd:
                    d8:80:b9:2d:b3:f0:9d:0f:eb:c8:f7:0e:a9:2e:7a:
                    1c:dc:c6:41:7b:11:d8:3e:74:13:82:ad:7a:74:49:
                    2c:5c:e8:fc:65:da:86:8b:f1:8b:e8:a9:8b:a2:31:
                    42:31:07:19:8b:cf:fc:51:25:2b:bb:4e:00:64:09:
                    b5:1e:37:9a:56:04:09:3b:0a:d9:5e:06:cf:ad:a2:
                    7b:5c:1f:18:87:1a:65:65:c0:df:c7:88:94:9a:98:
                    a1:e0:11:bb:12:da:15:c7:f8:c3:fa:5a:82:c9:5b:
                    09:2b:c9:43:8d:b0:86:c5:43:2b:bf:5b:2b:6f:87:
                    3d:30:c5:ce:9a:f2:88:67:a4:1d:44:a4:de:8d:c6:
                    d5:10:d2:a0:e9:0e:fc:43:87:5e:81:95:03:3f:93:
                    2a:71:e4:7e:10:67:3b:c9:b4:d8:c4:fb:88:61:e3:
                    8e:f2:af:08:e4:38:2b:1c:61:49
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Subject Alternative Name:
                DNS:siteA.192.168.33.10.xip.io, URI:https://siteA.192.168.33.10.xip.io/shibboleth
            X509v3 Subject Key Identifier:
                E1:82:69:2F:62:DF:08:72:FA:3B:AA:89:52:52:AE:C3:8B:BA:71:9F
    Signature Algorithm: sha256WithRSAEncryption
         63:09:74:21:86:14:16:36:96:a3:fd:d3:69:d1:b0:65:c4:cf:
         f7:2b:3b:bc:a6:7b:f1:38:31:ee:15:ba:9a:fb:d9:2e:dd:af:
         f0:4a:ec:e9:9e:ce:58:27:09:8d:23:aa:25:49:52:0e:6e:7a:
         be:ca:d6:a0:a6:45:27:a1:b1:d4:57:e3:b0:7e:8b:50:73:86:
         b4:04:89:ea:4b:02:11:31:ef:f9:a1:97:8c:bb:c0:9f:69:c6:
         ae:cc:8f:93:70:df:0c:aa:a8:68:7e:a9:45:cc:22:f9:90:25:
         23:03:ec:aa:6c:ab:79:6e:25:f8:2c:52:89:41:a7:9f:2b:34:
         bd:d2:c7:b7:a9:47:ee:1e:ce:3d:94:93:d8:b9:48:e3:78:2c:
         eb:79:f4:3b:e9:e5:19:37:05:e3:c0:9c:63:58:42:b4:59:68:
         03:e6:7e:ad:88:ef:b7:ec:23:63:a4:de:d8:05:92:89:bc:37:
         c7:f0:fa:98:5f:f7:9c:78:38:06:4a:a4:3e:0a:d7:7e:d1:84:
         86:90:6f:d3:64:17:17:aa:1c:24:d3:c7:f5:93:57:1b:7f:e2:
         ea:d4:62:88:4c:c8:0e:6d:51:9e:00:cb:9f:69:94:f4:32:33:
         73:95:5b:fd:40:14:52:9a:59:02:92:ba:9c:78:52:29:f4:03:
         4b:75:c4:4d:59:91:c8:27:86:ed:67:55:ed:b9:11:d3:70:1a:
         77:07:28:2f:70:f5:6a:82:77:34:bb:12:51:1a:cc:ed:e3:b3:
         69:0a:da:83:50:7d:ad:f1:d4:ef:9d:6e:40:1c:5c:b3:4e:2c:
         59:81:77:22:60:c8:12:89:6c:c8:51:90:b4:13:f6:fe:13:43:
         4d:b6:de:b4:7c:70:b8:9f:4b:fc:1a:d5:45:3a:12:e2:12:77:
         78:db:af:37:a2:54:db:dc:bc:6b:37:48:81:af:2b:2f:ce:71:
         00:83:69:c3:e3:f7:bb:2c:ce:1f:9e:a4:83:41:54:75:eb:5c:
         c6:ab:6d:ab:8b:c1



I can verify that the SP is telling the IdP to use the correct application override due to the audit log:

INFO [Shibboleth-Audit.SSO:241] - 20161102T040728Z|urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect|_155db44077d8fa6c421e7012ffcce869|https://siteA.192.168.33.10.xip.io/shibboleth|http://shibboleth.net/ns/profiles/saml2/sso/browser|https://idp-test.otago.ac.nz/idp/shibboleth|urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST|.....



Thanks so much for reading; hopefully someone can spot the devil in these details.

Cheers,
Cameron

-- 
CAMERON KERR
SYSTEMS ENGINEER
INFRASTRUCTURE & APPLICATIONS ITS
UNIVERSITY OF OTAGO



More information about the users mailing list