ソースを参照

增加解密验证

liaofei 2 年 前
コミット
2a8edb6d4e
1 ファイル変更7 行追加1 行削除
  1. 7 1
      crmeb/crmeb/utils/Rsa.php

+ 7 - 1
crmeb/crmeb/utils/Rsa.php

@@ -13,6 +13,8 @@
 
 
 namespace crmeb\utils;
 namespace crmeb\utils;
 
 
+use think\exception\ValidateException;
+
 /**
 /**
  * Class Rsa
  * Class Rsa
  * @author 等风来
  * @author 等风来
@@ -186,7 +188,11 @@ class Rsa
             $this->exportOpenSSLFile();
             $this->exportOpenSSLFile();
         }
         }
 
 
-        openssl_private_decrypt(base64_decode($data), $decryptedData, file_get_contents($this->privateKey));
+        $res = openssl_private_decrypt(base64_decode($data), $decryptedData, file_get_contents($this->privateKey));
+
+        if (false === $res) {
+            throw new ValidateException('RSA:解密失败');
+        }
 
 
         return $decryptedData;
         return $decryptedData;
     }
     }