From 27b720957c4813ebbb4520e85e900fe671b2b48c Mon Sep 17 00:00:00 2001 From: Michael_xu Date: Fri, 5 Mar 2021 15:04:18 +0800 Subject: [PATCH] update --- application/admin/common.php | 18 +++++++++++++++--- config/config.php | 6 ++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/application/admin/common.php b/application/admin/common.php index ef3fe9e..54d3320 100644 --- a/application/admin/common.php +++ b/application/admin/common.php @@ -173,11 +173,11 @@ function sendRequest($url, $params = array() , $headers = array()) { /** * 验证序列号 - * @param + * @param * @return - */ + */ function checkWkCode($wkcode) { - $pub = config('public_key'); + $pub = formatPubKey(config('public_key')); $openssl_pub = openssl_pkey_get_public($pub); // 验签 $resArr = openssl_public_decrypt(Hex2String($wkcode), $decrypted, $pub); @@ -192,3 +192,15 @@ function Hex2String($hex){ } return $string; } + +//公钥格式处理 +function formatPubKey($pubKey) { + $fKey = "-----BEGIN PUBLIC KEY-----\n"; + $len = strlen($pubKey); + for($i = 0; $i < $len; ) { + $fKey = $fKey . substr($pubKey, $i, 64) . "\n"; + $i += 64; + } + $fKey .= "-----END PUBLIC KEY-----"; + return $fKey; +} \ No newline at end of file diff --git a/config/config.php b/config/config.php index 64285ae..22b465c 100644 --- a/config/config.php +++ b/config/config.php @@ -187,7 +187,7 @@ return [ // 缓存前缀 'prefix' => '', // 缓存有效期 0表示永久缓存 - 'expire' => 86400*3, + 'expire' => 86400*30, // 禁用缓存子目录 'cache_subdir' => false, 'redis' => [ @@ -266,7 +266,5 @@ return [ 'bi_cache_time' => 1800, // 商业智能慢查询查询时间(查询超过该时间进行数据缓存)(毫秒) 'bi_slow_query_time' => 500, - 'public_key' => '-----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkqKFcAQtIp4rlkB5LOMnViyVY/hhA6x0R9ftwtEXsAFu4hBZrm9txdEvxSrDCUsx3Zwv/gdimeOzTtfSKffdoE/DwllNP9Zu6nsr2kGRgPrRwjtlO+j2FOM0b9UY1SQ/bWE+a9oQL2jL9xMSbtX1xG/+HcMo1bT+pa6FNQzs3egmvMt75/jaxINPSraj4kgNFawSBk7qDBEqDYiQwtPTuaNW1YZIs++/gZHsCRgGs/JrAbxNpl7+v/+Z503I3I2rs/8eUM5d16NXR8M7vtobUDCTIiQOgRahO8WMadgFlwavyVCYhy/TBXyj5RUfWaS26LrEN3vkj4TjoJu5m9LQ5QIDAQAB ------END PUBLIC KEY-----', + 'public_key' => 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkqKFcAQtIp4rlkB5LOMnViyVY/hhA6x0R9ftwtEXsAFu4hBZrm9txdEvxSrDCUsx3Zwv/gdimeOzTtfSKffdoE/DwllNP9Zu6nsr2kGRgPrRwjtlO+j2FOM0b9UY1SQ/bWE+a9oQL2jL9xMSbtX1xG/+HcMo1bT+pa6FNQzs3egmvMt75/jaxINPSraj4kgNFawSBk7qDBEqDYiQwtPTuaNW1YZIs++/gZHsCRgGs/JrAbxNpl7+v/+Z503I3I2rs/8eUM5d16NXR8M7vtobUDCTIiQOgRahO8WMadgFlwavyVCYhy/TBXyj5RUfWaS26LrEN3vkj4TjoJu5m9LQ5QIDAQAB', ];