Unable to validate Signature

Implementace(1) - Získání adresy pro přesměrování uživatele

Prvním krokem je získání informací z metadat IdP

V dokumentaci je uveden odkaz na metadata NIA IdP FederationMetadata.xml

Více informací o NIA IdP metadatech je uvedeno na stránce IdP - Úvod

Postup

  1. Stažení souboru metadat
  2. Ověření obsahu metadat (dle RSA-SHA256 signatury XMLDSIG)
  3. Získání adresy pro přesměrování uživatele

1. stažení souboru a parsování jeho dat

    
 <?php
 // použijeme knihovnu simplesamlphp/saml2 z https://github.com/simplesamlphp/saml2
 use SAML2\XML\md\EntityDescriptor;
 use SAML2\DOMDocumentFactory;

 $metadata_url = "https://tnia.identitaobcana.cz/FPSTS/FederationMetadata/2007-06/FederationMetadata.xml";
 $metadata_string = file_get_contents($metadata_url);
 $metadata_dom = DOMDocumentFactory::fromString($metadata_string);
 $metadata = new EntityDescriptor($metadata_dom->documentElement);
 // také lze využít metodu DOMDocumentFactory::fromFile($filepath); pokud máte metadata stažena lokálně

Objekt následovně obsahuje tato data:
^ SAML2\XML\md\EntityDescriptor {#87
  -entityID: "urn:microsoft:cgg2010:fpsts"
  -ID: "_a97bfca6-c62b-4771-a2d4-b5bc17a4ed06"
  -Extensions: []
  -RoleDescriptor: array:2 [
    0 => SAML2\XML\md\UnknownRoleDescriptor {#95
      -xml: SAML2\XML\Chunk {#97
        -localName: "RoleDescriptor"
        -namespaceURI: "urn:oasis:names:tc:SAML:2.0:metadata"
        -xml: DOMElement {#99
          +nodeName: "RoleDescriptor"
          +nodeValue: ""
          +nodeType: XML_ELEMENT_NODE
          +parentNode: null
          +childNodes: DOMNodeList {#132
            +length: 5
          }
          +firstChild: DOMElement {#134 …}
          +lastChild: DOMElement {#136 …}
          +previousSibling: null
          +nextSibling: null
          +attributes: DOMNamedNodeMap {#139
            +length: 2
          }
          +ownerDocument: DOMDocument {#141 …}
          +namespaceURI: "urn:oasis:names:tc:SAML:2.0:metadata"
          +prefix: ""
          +localName: "RoleDescriptor"
          +baseURI: null
          +textContent: ""
          +tagName: "RoleDescriptor"
          +schemaTypeInfo: null
        }
      }
      -elementName: "md:RoleDescriptor"
      -ID: null
      -protocolSupportEnumeration: array:1 [
        0 => "http://docs.oasis-open.org/wsfed/federation/200706"
      ]
      -errorURL: null
      -Extensions: []
      -KeyDescriptor: array:1 [
        0 => SAML2\XML\md\KeyDescriptor {#96
          -use: "signing"
          -KeyInfo: SAML2\XML\ds\KeyInfo {#92
            -Id: null
            -info: array:1 [
              0 => SAML2\XML\ds\X509Data {#102
                -data: array:1 [
                  0 => SAML2\XML\ds\X509Certificate {#104
                    -certificate: "MIIH0jCCBbqgAwIBAgIEAVjUZzANBgkqhkiG9w0BAQsFADBpMQswCQYDVQQGEwJDWjEXMBUGA1UEYRMOTlRSQ1otNDcxMTQ5ODMxHTAbBgNVBAoMFMSMZXNrw6EgcG/FoXRhLCBzLnAuMSIwIAYDVQQDExlQb3N0U2lnbnVtIFF1YWxpZmllZCBDQSA0MB4XDTIyMDMxMTA3NTEyNloXDTIzMDMzMTA3NTEyNloweTELMAkGA1UEBhMCQ1oxFzAVBgNVBGETDk5UUkNaLTcyMDU0NTA2MScwJQYDVQQKDB5TcHLDoXZhIHrDoWtsYWRuw61jaCByZWdpc3Ryxa8xFjAUBgNVBAMMDUdHX0ZQU1RTX1RFU1QxEDAOBgNVBAUTB1MyNzU3MzAwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC5Ls3pWnNohUtQPvsTkqLbBs40/Yx05eLGQ8PfHtuZriCAjHOqaHUN9KOIvPV0pdgLy4PYCpOjOf2EQyOuP0oBk7Hq2+9atIZbA01/SUynR2w6GyAosCdoSJwWBR4lp62Ld0wGg8glgO83peADC7yIcZ+M9ZjhJeWcwyP71AfP35MdIJdLzaGX6prT9viUwu5O8xrvs1pqZ8ksk2ZRiLc9eTUaiVoMZ35026FMT82HFdcZMuMi0mFSJLw98pA92OAi/WGhy1ihh+LGxK2BbFyE6FD8z/cKSau+Q0v+57Wg6gWq+pi8ZfN5XRC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LmN6L2NybC9wc3F1YWxpZmllZGNhNC5jcmwwNaAzoDGGL2h0dHA6Ly9jcmwucG9zdHNpZ251bS5ldS9jcmwvcHNxdWFsaWZpZWRjYTQuY3JsMB0GA1UdDgQWBBSCtStzngo8o0QmO5SqPS1mfPhrFTANBgkqhkiG9w0BAQsFAAOCAgEAM+0izVaNJakTg8HHhkFyYAupCszr8B0Q3paAsNkrbEQpFK9hGOxB76lqamlfPSgydmqAvBCXbgFQ9KQ2TZ+x9fNuYABJHPVbBAnegAPgDhj/HjSCY15SFD3U4D1eQtZ+lN1KKMYOIMhGY6wiMkQXh0+4NQ9tJoB8dyFFEtoW/wm+RcFyMqYKlzVPHHZDigDalTdHkFoQnyK0GCfE3mhSWRLT8bKI9um8xdinbM4VjmMuocQ2r/TpO0kvJy/bV0Po/o0YRZMw3ExTOqd2ubFltDE/M2LxI+6OnRITjV++XAWUcrDRYzq+SLT/mxIO207jGqcXUxxRjWWPPBFOWStVlJ4wWenAel0XW1mAMFwmOwJ9sgix2OdUYteCIqpakgM13tRtSU+TCV33MrRpbxB9T50ucG6QYILDCeSq6Q45zqi8d/2wmX5vIV3n8TT0XyN+/KrX5kIO5ozTnPIGtIh6/C4jn8i0J4Z1VycuP0V9RPL55hZDJFYuTHxuBp3C0wpkjRs86J8X9dJG+Ex2TCdp3zx+V2PRDZv7S/4cU6ah0YJUXS2LZM1X4rTzHK7367LcWdvIsmDp1D7I9AwBsDLMAn4SdEmjBa2RO9wx3SHxkG9JFEyiET38l6kjmFqZtRBZOSu2A0lB0nDExJ4BENuGFQ5q+lonazSY+e7i623FhQg="
                  }
                ]
              }
            ]
          }
          -EncryptionMethod: []
        }
      ]
      -Organization: null
      -ContactPerson: []
      -validators: []
      +validUntil: null
      +cacheDuration: null
      #signatureKey: null
      #certificates: []
    }
    1 => SAML2\XML\md\IDPSSODescriptor {#94
      -WantAuthnRequestsSigned: null
      -SingleSignOnService: array:2 [
        0 => SAML2\XML\md\EndpointType {#107
          -Binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
          -Location: "https://tnia.identitaobcana.cz/FPSTS/saml2/basic"
          -ResponseLocation: null
          -attributes: []
        }
        1 => SAML2\XML\md\EndpointType {#113
          -Binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
          -Location: "https://tnia.identitaobcana.cz/FPSTS/saml2/basic"
          -ResponseLocation: null
          -attributes: []
        }
      ]
      -NameIDMappingService: []
      -AssertionIDRequestService: []
      -AttributeProfile: []
      -Attribute: []
      -ArtifactResolutionService: []
      -SingleLogoutService: array:1 [
        0 => SAML2\XML\md\EndpointType {#103
          -Binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
          -Location: "https://tnia.identitaobcana.cz/FPSTS/saml2/basic"
          -ResponseLocation: null
          -attributes: []
        }
      ]
      -ManageNameIDService: []
      -NameIDFormat: []
      -elementName: "md:IDPSSODescriptor"
      -ID: null
      -protocolSupportEnumeration: array:1 [
        0 => "urn:oasis:names:tc:SAML:2.0:protocol"
      ]
      -errorURL: null
      -Extensions: []
      -KeyDescriptor: array:1 [
        0 => SAML2\XML\md\KeyDescriptor {#101
          -use: "signing"
          -KeyInfo: SAML2\XML\ds\KeyInfo {#105
            -Id: null
            -info: array:1 [
              0 => SAML2\XML\ds\X509Data {#109
                -data: array:1 [
                  0 => SAML2\XML\ds\X509Certificate {#111
                    -certificate: "MIIH0jCCBbqgAwIBAgIEAVjUZzANBgkqhkiG9w0BAQsFADBpMQswCQYDVQQGEwJDWjEXMBUGA1UEYRMOTlRSQ1otNDcxMTQ5ODMxHTAbBgNVBAoMFMSMZXNrw6EgcG/FoXRhLCBzLnAuMSIwIAYDVQQDExlQb3N0U2lnbnVtIFF1YWxpZmllZCBDQSA0MB4XDTIyMDMxMTA3NTEyNloXDTIzMDMzMTA3NTEyNloweTELMAkGA1UEBhMCQ1oxFzAVBgNVBGETDk5UUkNaLTcyMDU0NTA2MScwJQYDVQQKDB5TcHLDoXZhIHrDoWt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IO5ozTnPIGtIh6/C4jn8i0J4Z1VycuP0V9RPL55hZDJFYuTHxuBp3C0wpkjRs86J8X9dJG+Ex2TCdp3zx+V2PRDZv7S/4cU6ah0YJUXS2LZM1X4rTzHK7367LcWdvIsmDp1D7I9AwBsDLMAn4SdEmjBa2RO9wx3SHxkG9JFEyiET38l6kjmFqZtRBZOSu2A0lB0nDExJ4BENuGFQ5q+lonazSY+e7i623FhQg="
                  }
                ]
              }
            ]
          }
          -EncryptionMethod: []
        }
      ]
      -Organization: null
      -ContactPerson: []
      -validators: []
      +validUntil: null
      +cacheDuration: null
      #signatureKey: null
      #certificates: []
    }
  ]
  -AffiliationDescriptor: null
  -Organization: null
  -ContactPerson: []
  -AdditionalMetadataLocation: []
  -validators: array:1 [
    0 => array:2 [
      "Function" => array:2 [
        0 => "SAML2\Utils"
        1 => "validateSignature"
      ]
      "Data" => array:2 [
        "Signature" => RobRichards\XMLSecLibs\XMLSecurityDSig {#85
          +sigNode: DOMElement {#90
            +nodeName: "Signature"
            +nodeValue: ""
            +nodeType: XML_ELEMENT_NODE
            +parentNode: null
            +childNodes: DOMNodeList {#157
              +length: 3
            }
            +firstChild: DOMElement {#161 …}
            +lastChild: DOMElement {#163 …}
            +previousSibling: null
            +nextSibling: null
            +attributes: DOMNamedNodeMap {#166
              +length: 0
            }
            +ownerDocument: DOMDocument {#168 …}
            +namespaceURI: "http://www.w3.org/2000/09/xmldsig#"
            +prefix: ""
            +localName: "Signature"
            +baseURI: "/nix/store/yxhh1ar4rlrniz3r7rpf2i87iw3z7py3-nia.otevrenamesta.cz/webroot/"
            +textContent: ""
            +tagName: "Signature"
            +schemaTypeInfo: null
          }
          +idKeys: array:1 [
            0 => "ID"
          ]
          +idNS: []
          -signedInfo: "<SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></CanonicalizationMethod><SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"></SignatureMethod><Reference URI="#_a97bfca6-c62b-4771-a2d4-b5bc17a4ed06"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform><Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></Transform></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod><DigestValue>iSp3M6csZGssmnP0zn/xGLfEE3QIecUr5PPeuV/0z18=</DigestValue></Reference></SignedInfo>"
          -xPathCtx: DOMXPath {#89
            +document: DOMDocument {#168 …}
          }
          -canonicalMethod: null
          -prefix: "ds:"
          -searchpfx: "secdsig"
          -validatedNodes: array:1 [
            "_a97bfca6-c62b-4771-a2d4-b5bc17a4ed06" => DOMElement {#86
              +nodeName: "EntityDescriptor"
              +nodeValue: ""
              +nodeType: XML_ELEMENT_NODE
              +parentNode: DOMDocument {#168 …}
              +childNodes: DOMNodeList {#125
                +length: 2
              }
              +firstChild: DOMElement {#131 …}
              +lastChild: DOMElement {#192 …}
              +previousSibling: null
              +nextSibling: null
              +attributes: DOMNamedNodeMap {#189
                +length: 2
              }
              +ownerDocument: DOMDocument {#168 …}
              +namespaceURI: "urn:oasis:names:tc:SAML:2.0:metadata"
              +prefix: ""
              +localName: "EntityDescriptor"
              +baseURI: "/nix/store/yxhh1ar4rlrniz3r7rpf2i87iw3z7py3-nia.otevrenamesta.cz/webroot/"
              +textContent: ""
              +tagName: "EntityDescriptor"
              +schemaTypeInfo: null
            }
          ]
        }
        "Certificates" => array:1 [
          0 => "MIIH0jCCBbqgAwIBAgIEAVjUZzANBgkqhkiG9w0BAQsFADBpMQswCQYDVQQGEwJDWjEXMBUGA1UEYRMOTlRSQ1otNDcxMTQ5ODMxHTAbBgNVBAoMFMSMZXNrw6EgcG/FoXRhLCBzLnAuMSIwIAYDVQQDExlQb3N0U2lnbnVtIFF1YWxpZmllZCBDQSA0MB4XDTIyMDMxMTA3NTEyNloXDTIzMDMzMTA3NTEyNloweTELMAk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teCIqpakgM13tRtSU+TCV33MrRpbxB9T50ucG6QYILDCeSq6Q45zqi8d/2wmX5vIV3n8TT0XyN+/KrX5kIO5ozTnPIGtIh6/C4jn8i0J4Z1VycuP0V9RPL55hZDJFYuTHxuBp3C0wpkjRs86J8X9dJG+Ex2TCdp3zx+V2PRDZv7S/4cU6ah0YJUXS2LZM1X4rTzHK7367LcWdvIsmDp1D7I9AwBsDLMAn4SdEmjBa2RO9wx3SHxkG9JFEyiET38l6kjmFqZtRBZOSu2A0lB0nDExJ4BENuGFQ5q+lonazSY+e7i623FhQg="
        ]
      ]
    ]
  ]
  +validUntil: null
  +cacheDuration: null
  #signatureKey: null
  #certificates: array:1 [
    0 => "MIIH0jCCBbqgAwIBAgIEAVjUZzANBgkqhkiG9w0BAQsFADBpMQswCQYDVQQGEwJDWjEXMBUGA1UEYRMOTlRSQ1otNDcxMTQ5ODMxHTAbBgNVBAoMFMSMZXNrw6EgcG/FoXRhLCBzLnAuMSIwIAYDVQQDExlQb3N0U2lnbnVtIFF1YWxpZmllZCBDQSA0MB4XDTIyMDMxMTA3NTEyNloXDTIzMDMzMTA3NTEyNloweTELMAkGA1UEBhMCQ1oxFzAVBgNVBGETDk5UUkNaLTcyMDU0NTA2MScwJQYDVQQKDB5TcHLDoXZhIHrDoWtsYWRuw61jaCByZWdpc3Ryxa8xFjAUBgNVBAMMDUdHX0ZQU1RTX1RFU1QxEDAOBgNVBAUTB1MyNzU3MzAwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC5Ls3pWnNohUtQPvsTkqLbBs40/Yx05eLGQ8PfHtuZriCAjHOqaHUN9KOIvPV0pdgLy4PYCpOjOf2EQyOuP0oBk7Hq2+9atIZbA01/SUynR2w6GyAosCdoSJwWBR4lp62Ld0wGg8glgO83peADC7yIcZ+M9ZjhJeWcwyP71AfP35MdIJdLzaGX6prT9viUwu5O8xrvs1pqZ8ksk2ZRiLc9eTUaiVoMZ35026FMT82HFdcZMuMi0mFSJL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wvcHNxdWFsaWZpZWRjYTQuY3JsMDagNKAyhjBodHRwOi8vY3JsMi5wb3N0c2lnbnVtLmN6L2NybC9wc3F1YWxpZmllZGNhNC5jcmwwNaAzoDGGL2h0dHA6Ly9jcmwucG9zdHNpZ251bS5ldS9jcmwvcHNxdWFsaWZpZWRjYTQuY3JsMB0GA1UdDgQWBBSCtStzngo8o0QmO5SqPS1mfPhrFTANBgkqhkiG9w0BAQsFAAOCAgEAM+0izVaNJakTg8HHhkFyYAupCszr8B0Q3paAsNkrbEQpFK9hGOxB76lqamlfPSgydmqAvBCXbgFQ9KQ2TZ+x9fNuYABJHPVbBAnegAPgDhj/HjSCY15SFD3U4D1eQtZ+lN1KKMYOIMhGY6wiMkQXh0+4NQ9tJoB8dyFFEtoW/wm+RcFyMqYKlzVPHHZDigDalTdHkFoQnyK0GCfE3mhSWRLT8bKI9um8xdinbM4VjmMuocQ2r/TpO0kvJy/bV0Po/o0YRZMw3ExTOqd2ubFltDE/M2LxI+6OnRITjV++XAWUcrDRYzq+SLT/mxIO207jGqcXUxxRjWWPPBFOWStVlJ4wWenAel0XW1mAMFwmOwJ9sgix2OdUYteCIqpakgM13tRtSU+TCV33MrRpbxB9T50ucG6QYILDCeSq6Q45zqi8d/2wmX5vIV3n8TT0XyN+/KrX5kIO5ozTnPIGtIh6/C4jn8i0J4Z1VycuP0V9RPL55hZDJFYuTHxuBp3C0wpkjRs86J8X9dJG+Ex2TCdp3zx+V2PRDZv7S/4cU6ah0YJUXS2LZM1X4rTzHK7367LcWdvIsmDp1D7I9AwBsDLMAn4SdEmjBa2RO9wx3SHxkG9JFEyiET38l6kjmFqZtRBZOSu2A0lB0nDExJ4BENuGFQ5q+lonazSY+e7i623FhQg="
  ]
}

2. Ověření obsahu souboru

    
 <?php
 use RobRichards\XMLSecLibs\XMLSecurityKey;

 // soubor s certifikátem bychom měli mít uložen lokálně, aby validace podpisu proběhla korektně
 // na uvedené adrese je uložen NIA certifikát (PEM) z testovacího prostředí
 $tnia_cert_data = file_get_contents('https://nia.otevrenamesta.cz/tnia.crt');
 // z dat certifikátu vytvoříme klíč
 $tnia_key = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, ['type' => 'public']);
 $tnia_key->loadKey($tnia_cert_data, false, true);
 // a použijeme interní metodu EntityDescriptor->validate(XMLSecurityKey $key) pro validaci
 $valid = $metadata->validate($tnia_key);

    
Obsah proměnné valid:
Notice (8): Undefined variable: valid [APP/Template/Pages/example_step1.ctp, line 66]
^ null

3. Získání adresy pro přesměrování uživatele

    
    <?php
    use SAML2\Constants;
    use SAML2\XML\md\IDPSSODescriptor;
    use SAML2\XML\md\EntityDescriptor;

    private function extractSSOLoginUrls(EntityDescriptor $idp_descriptor){
        $idp_sso_descriptor = false;
        foreach ($idp_descriptor->getRoleDescriptor() as $role_descriptor) {
            if ($role_descriptor instanceof IDPSSODescriptor) {
                $idp_sso_descriptor = $role_descriptor;
            }
        }

        $sso_redirect_login_url = false;
        $sso_post_login_url = false;

        if ($idp_sso_descriptor instanceof IDPSSODescriptor) {
            foreach ($idp_sso_descriptor->getSingleSignOnService() as $descriptorType) {
                if ($descriptorType->getBinding() === Constants::BINDING_HTTP_REDIRECT) {
                    $sso_redirect_login_url = $descriptorType->getLocation();
                } else if ($descriptorType->getBinding() === Constants::BINDING_HTTP_POST) {
                    $sso_post_login_url = $descriptorType->getLocation();
                }
            }
        }

        return [Constants::BINDING_HTTP_REDIRECT => $sso_redirect_login_url, Constants::BINDING_HTTP_POST => $sso_post_login_url];
    }

    $urls = extractSSOLoginUrls($metadata);
    $redirect_url = $urls[Constants::BINDING_HTTP_REDIRECT];
    $post_url = $urls[Constants::BINDING_HTTP_POST];
    
Obsah proměnné urls:
^ array:2 [
  "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" => "https://tnia.identitaobcana.cz/FPSTS/saml2/basic"
  "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" => "https://tnia.identitaobcana.cz/FPSTS/saml2/basic"
]