RobRichards\XMLSecLibs\XMLSecurityKey::getRawThumbprint PHP Method

getRawThumbprint() public static method

Get the raw thumbprint of a certificate
public static getRawThumbprint ( string $cert ) : null | string
$cert string
return null | string
    public static function getRawThumbprint($cert)
    {
        $arCert = explode("\n", $cert);
        $data = '';
        $inData = false;
        foreach ($arCert as $curData) {
            if (!$inData) {
                if (strncmp($curData, '-----BEGIN CERTIFICATE', 22) == 0) {
                    $inData = true;
                }
            } else {
                if (strncmp($curData, '-----END CERTIFICATE', 20) == 0) {
                    break;
                }
                $data .= trim($curData);
            }
        }
        if (!empty($data)) {
            return strtolower(sha1(base64_decode($data)));
        }
        return null;
    }

Usage Example

コード例 #1
0
ファイル: X509Certificate.php プロジェクト: aarnaud/lightSAML
 /**
  * @throws \LightSaml\Error\LightSamlException
  *
  * @return string
  */
 public function getFingerprint()
 {
     if (false == $this->data) {
         throw new LightSamlException('Certificate data not set');
     }
     return XMLSecurityKey::getRawThumbprint($this->toPem());
 }