Authored by Rock Zhang

修复银联支付的证书路径错误的bug

Code Review By Rock Zhang
... ... @@ -3,8 +3,7 @@
function EncryptedPin($sPin, $sCardNo ,$sPubKeyURL)
{
global $log;
$sPubKeyURL = trim(dirname(__FILE__) . '/../../' . SDK_ENCRYPT_CERT_PATH," ");
// $log->LogInfo("DisSpaces : " . PubKeyURL);
$sPubKeyURL = trim(dirname(__FILE__) . '/../' . SDK_ENCRYPT_CERT_PATH," ");
$fp = fopen($sPubKeyURL, "r");
if ($fp != NULL)
{
... ...
... ... @@ -23,7 +23,8 @@ function sign(&$params)
$params_sha1x16 = sha1($params_str, FALSE);
$log->LogInfo("摘要sha1x16 >" . $params_sha1x16);
// 签名证书路径
$cert_path = dirname(__FILE__) . '/../../' . SDK_SIGN_CERT_PATH;
$cert_path = dirname(__FILE__) . '/../' . SDK_SIGN_CERT_PATH;
$log->logInfo($cert_path);
$private_key = getPrivateKey($cert_path);
// 签名
$sign_falg = openssl_sign($params_sha1x16, $signature, $private_key, OPENSSL_ALGO_SHA1);
... ... @@ -74,7 +75,7 @@ function getPulbicKeyByCertId($certId)
$log = new PhpLog (SDK_LOG_FILE_PATH, "PRC", SDK_LOG_LEVEL);
$log->LogInfo('报文返回的证书ID>' . $certId);
// 证书目录
$cert_dir = dirname(__FILE__) . '/../../' . SDK_VERIFY_CERT_DIR;
$cert_dir = dirname(__FILE__) . '/../' . SDK_VERIFY_CERT_DIR;
$log->LogInfo('验证签名证书目录 :>' . $cert_dir);
$handle = opendir($cert_dir);
if ($handle) {
... ... @@ -139,13 +140,13 @@ function getSignCertId()
{
// 签名证书路径
return getCertId(dirname(__FILE__) . '/../../' . SDK_SIGN_CERT_PATH);
return getCertId(dirname(__FILE__) . '/../' . SDK_SIGN_CERT_PATH);
}
function getEncryptCertId()
{
// 签名证书路径
return getCertIdByCerPath(dirname(__FILE__) . '/../../' . SDK_ENCRYPT_CERT_PATH);
return getCertIdByCerPath(dirname(__FILE__) . '/../' . SDK_ENCRYPT_CERT_PATH);
}
/**
... ... @@ -195,7 +196,7 @@ function encryptPan($pan)
*/
function encryptPin($pan, $pwd)
{
$cert_path = dirname(__FILE__) . '/../../' . SDK_ENCRYPT_CERT_PATH;
$cert_path = dirname(__FILE__) . '/../' . SDK_ENCRYPT_CERT_PATH;
$public_key = getPublicKey($cert_path);
return EncryptedPin($pwd, $pan, $public_key);
... ... @@ -209,7 +210,7 @@ function encryptPin($pan, $pwd)
*/
function encryptCvn2($cvn2)
{
$cert_path = dirname(__FILE__) . '/../../' . SDK_ENCRYPT_CERT_PATH;
$cert_path = dirname(__FILE__) . '/../' . SDK_ENCRYPT_CERT_PATH;
$public_key = getPublicKey($cert_path);
openssl_public_encrypt($cvn2, $crypted, $public_key);
... ... @@ -225,7 +226,7 @@ function encryptCvn2($cvn2)
*/
function encryptDate($certDate)
{
$cert_path = dirname(__FILE__) . '/../../' . SDK_ENCRYPT_CERT_PATH;
$cert_path = dirname(__FILE__) . '/../' . SDK_ENCRYPT_CERT_PATH;
$public_key = getPublicKey($cert_path);
openssl_public_encrypt($certDate, $crypted, $public_key);
... ... @@ -241,7 +242,7 @@ function encryptDate($certDate)
*/
function encryptDateType($certDataType)
{
$cert_path = dirname(__FILE__) . '/../../' . SDK_ENCRYPT_CERT_PATH;
$cert_path = dirname(__FILE__) . '/../' . SDK_ENCRYPT_CERT_PATH;
$public_key = getPublicKey($cert_path);
openssl_public_encrypt($certDataType, $crypted, $public_key);
... ...