$url_parts = parse_url($url);
$canonical_url = ($url_parts['path'] . (!empty($url_parts['query']) ? "?${url_parts['query']}" : ""));
$message = $http_method."\n".
$canonical_url."\n".
$timestamp."\n".
$nonce."\n".
$body."\n";
openssl_sign($message, $raw_sign, $mch_private_key, 'sha256WithRSAEncryption');
$sign = base64_encode($raw_sign);
https://www.php.net/manual/zh/function.openssl-sign.php
openssl_sign的第二个参数数一个传址参数,在openssl_sign执行后, $raw_sign就有值了
openssl_sign($message, $raw_sign, $mch_private_key, 'sha256WithRSAEncryption');
print_r($raw_sign)
--↓↓👍点赞是回答的动力哦