Example #1
0
/**
 * 根据证书ID 加载 证书
 *
 * @param unknown_type $certId        	
 * @return string NULL
 */
function getPulbicKeyByCertId($certId)
{
    //global $log;
    $log = new PhpLog(SDK_LOG_FILE_PATH, "PRC", SDK_LOG_LEVEL);
    $log->LogInfo('报文返回的证书ID>' . $certId);
    // 证书目录
    $cert_dir = SDK_VERIFY_CERT_DIR;
    $log->LogInfo('验证签名证书目录 :>' . $cert_dir);
    $handle = opendir($cert_dir);
    if ($handle) {
        while ($file = readdir($handle)) {
            clearstatcache();
            $filePath = $cert_dir . '/' . $file;
            if (is_file($filePath)) {
                if (pathinfo($file, PATHINFO_EXTENSION) == 'cer') {
                    if (getCertIdByCerPath($filePath) == $certId) {
                        closedir($handle);
                        $log->LogInfo('加载验签证书成功');
                        return getPublicKey($filePath);
                    }
                }
            }
        }
        $log->LogInfo('没有找到证书ID为[' . $certId . ']的证书');
    } else {
        $log->LogInfo('证书目录 ' . $cert_dir . '不正确');
    }
    closedir($handle);
    return null;
}
Example #2
0
function getEncryptCertId()
{
    return getCertIdByCerPath(SDK_ENCRYPT_CERT_PATH);
}