Skip to content

RSA2, Non-certificate mode, The signature is not match,同步异步回调验签失败 #175

@ltq918

Description

@ltq918

根据wiki指引,在同步和异步回调时报错 ‘The signature is not match’,最终解决了。
修改 src/Requests/AopNotifyRequest.php

protected function verifySignature(){
        $signer = new Signer($this->params->all());
        $signer->setSort($this->sort);
        $signer->setEncodePolicy($this->encodePolicy);

        $signer->setIgnores(['sign','sign_type']);      //Add this line

        $content = $signer->getContentToSign();
        $sign = $this->params->get('sign');
        $signType = $this->params->get('sign_type');
        if ($signType == 'RSA2') {
            $match = (new Signer)->verifyWithRSA($content, $sign, $this->getAlipayPublicKey(), OPENSSL_ALGO_SHA256);
        } else {
            $match = (new Signer)->verifyWithRSA($content, $sign, $this->getAlipayPublicKey());
        }
        if (! $match) {
            throw new InvalidRequestException('The signature is not match');
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions