Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6.0-dev 生成createV2Signature签名没有及时移除signType导致签名错误 #2721

Closed
exvu opened this issue Jul 4, 2023 · 1 comment

Comments

@exvu
Copy link

exvu commented Jul 4, 2023

我用的环境

生成createV2Signature签名没有及时移除signType导致签名错误

public function createV2Signature(array $params): string
    {
        $method = 'md5';
        $secretKey = $this->merchant->getV2SecretKey();

        if (empty($secretKey)) {
            throw new InvalidConfigException('Missing v2 secret key.');
        }

        if ('HMAC-SHA256' === $params['signType']) {
            $method = function ($str) use ($secretKey) {
                return hash_hmac('sha256', $str, $secretKey);
            };
        }
#源码没有这行 ,应该移除参数
        unset($params['signType']);

        ksort($params);

        $params['key'] = $secretKey;
        // @phpstan-ignore-next-line
        return strtoupper((string) call_user_func_array($method, [urldecode(http_build_query($params))]));
    }
@exvu exvu changed the title 6.0-dev 生成createV2Signature签名没有及时移除signType导致前面错误 6.0-dev 生成createV2Signature签名没有及时移除signType导致签名错误 Jul 4, 2023
overtrue added a commit that referenced this issue Jul 5, 2023
@overtrue
Copy link
Collaborator

overtrue commented Jul 5, 2023

感谢反馈!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants