Validating a signature without intermediate certificate

可紊 提交于 2019-12-05 04:07:35

it depends whether your SAML response contains the signing certificate <ds:X509Data>...</ds:X509Data> or just the public key <ds:KeyValue>...</ds:KeyValue> of it.

<saml2p:Response xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" ...>
  ...
  <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
    <ds:SignedInfo>...</ds:SignedInfo
    <ds:SignatureValue>...</ds:SignatureValue>
    <ds:KeyInfo>
      <ds:X509Data>
        <ds:X509Certificate>...</ds:X509Certificate>
      </ds:X509Data>
    </ds:KeyInfo>
  </ds:Signature>
</saml2p:Response>

vs.

<saml2p:Response xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" ...>
  ...
  <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
    <ds:SignedInfo>...</ds:SignedInfo
    <ds:SignatureValue>...</ds:SignatureValue>
    <ds:KeyInfo>
      <ds:KeyValue>
        <ds:RSAKeyValue>
          <ds:Modulus>...</ds:Modulus>
          <ds:Exponent>...</ds:Exponent>
        </ds:RSAKeyValue>
      </ds:KeyValue>
    </ds:KeyInfo>
  </ds:Signature>
</saml2p:Response>

If the signing certificate is embedded, it may contain the AuthorityInfoAccess extension, which usually contains an http or ldap URL to the issuing CA certificate. Using these extensions from the signing certificate to the trusted CA certificate, you would be able to build the trusted certificate chain. (Note: If the CertCA is actually the direct issuer of CertIdP and CertSP you already have the required trusted certificate chain.)

However, if you only got the public key you need to have the signing certificate at hand to match the public key against. So then it comes down to a provisioning/distribution problem. You could provide a web service that returns the corresponding signing certificate for the requested public key. If the signing certificate was not found in the SP's local keystore it would contact the web service to retrieve the new CertIdP and add it to the local keystore. Keeping the local keystore is performance, availability and privacy relevant.

I'll start with some small introduction - the verification of digital signatures is done in two stages

  • first signature verification - which checks that the signature value is actually corresponding to the content it protects and that the content therefore wasn't tampered with
  • trust verification - check that the signature was made by someone trusted by the verifier).

Verification of a digital signature requires posession of the public key whose corresponding private key was used to create the signature. There's no way around this.

But there's one use-case for verification of trust which allows usage of CA certificates - and it should be helpful for your case.

It works so that you only include your CA (and possibly intermediate CA) signing certificates in the metadata generated for your SPs and IDPs. You then include the precise leaf key (issued by the CA) used to create the signature as part of the SAML message (in KeyInfo element inside the Signature). The SP/IDP is then able to verify that the leaf key (which was unknown to it beforehand) is trusted by constructing and verifying Certification Path using the CA certificates it already has.

It's useful for rollovers of keys (e.g. when they expire) - as SP and IDP can change their signing key without need to notify the other party. SAML products sometimes call this feature anchored or PKIX trust mode.

Please note that this approach doesn't work for digital encryption, as encryption requires beforehand knowledge of the precise leaf key of the other party.

The short answer is "No." If you only have the CA's certificate but not the certificate of the IdP or SP you cannot validate the signature of IdP or SP.

The longer answer: To validate the signature of the IdP by the SP, the SP first has to identify the correct public key associated with the IdP. Validation involves comparing the public-key-encrypted signature value with the hash of the content and checking that they are the same. Without the public key of the IdP the SP cannot perform this operation.

Suppose the SP has a public key that makes the validation above work, and it now wants to validate that this public key in fact belongs to the IdP. In order to do this, it needs a certificate that contains the public key and the name of the IdP, with a signature from a trusted entity, in this case the CA. Since you don't have this, you can't validate that the signature was performed by the IdP.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!