From f4a0c35ebb4b6f3a497f5fa4bf8c814119534e07 Mon Sep 17 00:00:00 2001 From: Rock Zhang <iamgtskk@gmail.com> Date: Mon, 25 Apr 2016 15:45:03 +0800 Subject: [PATCH] 修改银联支付有关的证书配置路径为相对路径 Code Review By Rock Zhang --- library/WebPlugin/Pay/Unionpayweb/Func/PublicEncrypte.php | 2 +- library/WebPlugin/Pay/Unionpayweb/Func/secureUtil.php | 14 +++++++------- library/WebPlugin/Pay/Unionpayweb/Service.php | 2 +- library/WebPlugin/Pay/Unionpayweb/conf/release/SDKConfig.php | 8 ++++---- library/WebPlugin/Pay/Unionpayweb/conf/test/SDKConfig.php | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/library/WebPlugin/Pay/Unionpayweb/Func/PublicEncrypte.php b/library/WebPlugin/Pay/Unionpayweb/Func/PublicEncrypte.php index b5510fd..8dcd874 100644 --- a/library/WebPlugin/Pay/Unionpayweb/Func/PublicEncrypte.php +++ b/library/WebPlugin/Pay/Unionpayweb/Func/PublicEncrypte.php @@ -3,7 +3,7 @@ function EncryptedPin($sPin, $sCardNo ,$sPubKeyURL) { global $log; - $sPubKeyURL = trim(SDK_ENCRYPT_CERT_PATH," "); + $sPubKeyURL = trim(dirname(__FILE__) . '/../../' . SDK_ENCRYPT_CERT_PATH," "); // $log->LogInfo("DisSpaces : " . PubKeyURL); $fp = fopen($sPubKeyURL, "r"); if ($fp != NULL) diff --git a/library/WebPlugin/Pay/Unionpayweb/Func/secureUtil.php b/library/WebPlugin/Pay/Unionpayweb/Func/secureUtil.php index 3617201..642c295 100644 --- a/library/WebPlugin/Pay/Unionpayweb/Func/secureUtil.php +++ b/library/WebPlugin/Pay/Unionpayweb/Func/secureUtil.php @@ -23,7 +23,7 @@ function sign(&$params) $params_sha1x16 = sha1($params_str, FALSE); $log->LogInfo("摘要sha1x16 >" . $params_sha1x16); // 签名证书路径 - $cert_path = SDK_SIGN_CERT_PATH; + $cert_path = dirname(__FILE__) . '/../../' . SDK_SIGN_CERT_PATH; $private_key = getPrivateKey($cert_path); // 签名 $sign_falg = openssl_sign($params_sha1x16, $signature, $private_key, OPENSSL_ALGO_SHA1); @@ -74,7 +74,7 @@ function getPulbicKeyByCertId($certId) $log = new PhpLog (SDK_LOG_FILE_PATH, "PRC", SDK_LOG_LEVEL); $log->LogInfo('报文返回的证书ID>' . $certId); // 证书目录 - $cert_dir = SDK_VERIFY_CERT_DIR; + $cert_dir = dirname(__FILE__) . '/../../' . SDK_VERIFY_CERT_DIR; $log->LogInfo('验证签名证书目录 :>' . $cert_dir); $handle = opendir($cert_dir); if ($handle) { @@ -145,7 +145,7 @@ function getSignCertId() function getEncryptCertId() { // 签名证书路径 - return getCertIdByCerPath(SDK_ENCRYPT_CERT_PATH); + return getCertIdByCerPath(dirname(__FILE__) . '/../../' . SDK_ENCRYPT_CERT_PATH); } /** @@ -195,7 +195,7 @@ function encryptPan($pan) */ function encryptPin($pan, $pwd) { - $cert_path = 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 +209,7 @@ function encryptPin($pan, $pwd) */ function encryptCvn2($cvn2) { - $cert_path = 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 +225,7 @@ function encryptCvn2($cvn2) */ function encryptDate($certDate) { - $cert_path = 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 +241,7 @@ function encryptDate($certDate) */ function encryptDateType($certDataType) { - $cert_path = SDK_ENCRYPT_CERT_PATH; + $cert_path = dirname(__FILE__) . '/../../' . SDK_ENCRYPT_CERT_PATH; $public_key = getPublicKey($cert_path); openssl_public_encrypt($certDataType, $crypted, $public_key); diff --git a/library/WebPlugin/Pay/Unionpayweb/Service.php b/library/WebPlugin/Pay/Unionpayweb/Service.php index ad8c5c0..154eed2 100644 --- a/library/WebPlugin/Pay/Unionpayweb/Service.php +++ b/library/WebPlugin/Pay/Unionpayweb/Service.php @@ -14,7 +14,7 @@ class Service extends PayAbstract public function __construct(array $paymentParams) { - $env = APPLICATION_ENV == 'production' ? 'release' : 'test'; + $env = (APPLICATION_ENV === 'production' || APPLICATION_ENV === 'preview') ? 'release' : 'test'; include_once 'conf/' . $env . '/SDKConfig.php'; include_once 'Func/common.php'; include_once 'Func/secureUtil.php'; diff --git a/library/WebPlugin/Pay/Unionpayweb/conf/release/SDKConfig.php b/library/WebPlugin/Pay/Unionpayweb/conf/release/SDKConfig.php index 0a6e61c..fecd27b 100644 --- a/library/WebPlugin/Pay/Unionpayweb/conf/release/SDKConfig.php +++ b/library/WebPlugin/Pay/Unionpayweb/conf/release/SDKConfig.php @@ -11,19 +11,19 @@ const SDK_PAN_ENC = 0; // 签名证书路径 (联系运营获取两码,在CFCA网站下载后配置,自行设置证书密码并配置) -const SDK_SIGN_CERT_PATH = '/Data/code/git/web/yohobuy/library/WebPlugin/Pay/Unionpayweb/conf/release/certs/pc_online_banking.pfx'; +const SDK_SIGN_CERT_PATH = 'conf/release/certs/pc_online_banking.pfx'; // 签名证书密码 const SDK_SIGN_CERT_PWD = 'yoho12'; // 验签证书 -const SDK_VERIFY_CERT_PATH = '/Data/code/git/web/yohobuy/library/WebPlugin/Pay/Unionpayweb/conf/release/certs/UpopRsaCert.cer'; +const SDK_VERIFY_CERT_PATH = 'conf/release/certs/UpopRsaCert.cer'; // 密码加密证书 -const SDK_ENCRYPT_CERT_PATH = '/Data/code/git/web/yohobuy/library/WebPlugin/Pay/Unionpayweb/conf/release/certs/RSA2048_PROD_index_22.cer'; +const SDK_ENCRYPT_CERT_PATH = 'conf/release/certs/RSA2048_PROD_index_22.cer'; // 验签证书路径 -const SDK_VERIFY_CERT_DIR = '/Data/code/git/web/yohobuy/library/WebPlugin/Pay/Unionpayweb/conf/release/certs/'; +const SDK_VERIFY_CERT_DIR = 'conf/release/certs/'; // 前台请求地址 const SDK_FRONT_TRANS_URL = 'https://gateway.95516.com/gateway/api/frontTransReq.do'; diff --git a/library/WebPlugin/Pay/Unionpayweb/conf/test/SDKConfig.php b/library/WebPlugin/Pay/Unionpayweb/conf/test/SDKConfig.php index e0780c7..711cd33 100644 --- a/library/WebPlugin/Pay/Unionpayweb/conf/test/SDKConfig.php +++ b/library/WebPlugin/Pay/Unionpayweb/conf/test/SDKConfig.php @@ -9,17 +9,17 @@ const SDK_PAN_ENC = 0; // ######(以下配置为PM环境:入网测试环境用,生产环境配置见文档说明)####### // 签名证书路径 //const SDK_SIGN_CERT_PATH = 'D:\\wamp\\www\\yohobuy\\library\\WebPlugin\\Pay\\Unionpayweb\\conf\\test\\certs\\PM_700000000000001_acp.pfx'; -const SDK_SIGN_CERT_PATH = '/Data/code/git/web/yohobuy/library/WebPlugin/Pay/Unionpayweb/conf/test/certs/PM_700000000000001_acp.pfx'; +const SDK_SIGN_CERT_PATH = 'conf/test/certs/PM_700000000000001_acp.pfx'; // 签名证书密码 const SDK_SIGN_CERT_PWD = '000000'; // 密码加密证书(这条用不到的请随便配) -const SDK_ENCRYPT_CERT_PATH = '/Data/code/git/web/yohobuy/library/WebPlugin/Pay/Unionpayweb/conf/test/certs/verify_sign_acp.cer'; +const SDK_ENCRYPT_CERT_PATH = 'conf/test/certs/verify_sign_acp.cer'; //const SDK_ENCRYPT_CERT_PATH = 'D:\\wamp\\www\\yohobuy\\library\\WebPlugin\\Pay\\Unionpayweb\\conf\\test\\certs\\verify_sign_acp.cer'; // 验签证书路径(请配到文件夹,不要配到具体文件) -const SDK_VERIFY_CERT_DIR = '/Data/code/git/web/yohobuy/library/WebPlugin/Pay/Unionpayweb/conf/test/certs/'; +const SDK_VERIFY_CERT_DIR = 'conf/test/certs/'; // 前台请求地址 const SDK_FRONT_TRANS_URL = 'https://101.231.204.80:5000/gateway/api/frontTransReq.do'; -- libgit2 0.24.0