sspmod_saml_Message::findCertificate PHP Method

findCertificate() private static method

An exception is thrown if we are unable to locate the certificate.
private static findCertificate ( array $certFingerprints, array $certificates ) : string
$certFingerprints array The fingerprints we are looking for.
$certificates array Array of certificates.
return string Certificate, in PEM-format.
    private static function findCertificate(array $certFingerprints, array $certificates)
    {
        $candidates = array();
        foreach ($certificates as $cert) {
            $fp = strtolower(sha1(base64_decode($cert)));
            if (!in_array($fp, $certFingerprints, TRUE)) {
                $candidates[] = $fp;
                continue;
            }
            /* We have found a matching fingerprint. */
            $pem = "-----BEGIN CERTIFICATE-----\n" . chunk_split($cert, 64) . "-----END CERTIFICATE-----\n";
            return $pem;
        }
        $candidates = "'" . implode("', '", $candidates) . "'";
        $fps = "'" . implode("', '", $certFingerprints) . "'";
        throw new SimpleSAML_Error_Exception('Unable to find a certificate matching the configured ' . 'fingerprint. Candidates: ' . $candidates . '; certFingerprint: ' . $fps . '.');
    }