视频一区二区三区自拍_千金肉奴隷1985未删减版在线观看_国产成人黄色视频在线播放_少女免费播放片高清在线观看_国产精品v欧美精品v

Login expired. Please log in again.

Feedback

0/300

Feedback

Submitted successfully

ok

Feedback

Network exception, please try again later

ok

Signature check FAQ

Is the signature method of the V2 and V3 interface the same?

No.
The signature at V2 interface is MD5 or HMAC-SHA256, and the signature at V3 interface is asymmetric key SHA256-RSA.

Why is the WeChat Pay callback missing several HTTP headers?

The WeChat Pay callback contains the following four HTTP headers in the HTTP header:
1、Wechatpay-Timestamp
2、Wechatpay-Nonce
3、Wechatpay-Singature
4、Wechatpay-Serial Some proxy servers or CDN service providers will "filter" the HTTP headers of WeChat Pay extensions when forwarding, causing the application layer of signature verification to fail to obtain the signature information of WeChat Pay.
In that case, merchants should adjust the proxy server configuration or accept WeChat Pay callbacks through direct connection.

Accept or User-Agent is missing in Http

The error is caused by the wrongly set basic rules.
Both Accept and User-Agent need to be set.
1. Please refer to the following to set up Accept setting:
Content-Type: application/json Accept: The application/ json
2. Refer to the following tips for the setting of User-Agent:
HTTP agreement requires the requesting client to use User-Agent in the HTTP header to identify itself in each request. WeChat Pay recommends that the caller choose one of the following two methods:
A. Use the default User-Agent of the HTTP client.
B. Follow the HTTP agreement, and use the name and version of the system and application to form the unique User-Agent.
Note:
1. The error only exists in the V3 interface.
2. WeChat Pay API V3 is likely to refuse to process requests without User-Agent.

How to Load a Private Key in a Program?

We recommend using the SDK provided by WeChat Pay. You can also view the sample codes in the following programming languages.

/**
  * 獲取私鑰。
  *
  * @param filename 私鑰文件路徑  (required)
  * @return 私鑰對(duì)象
  */
public static PrivateKey getPrivateKey(String filename) throws IOException {

  String content = new String(Files.readAllBytes(Paths.get(filename)), "utf-8");
  try {
    String privateKey = content.replace("-----BEGIN PRIVATE KEY-----", "")
        .replace("-----END PRIVATE KEY-----", "")
        .replaceAll("\\s+", "");

    KeyFactory kf = KeyFactory.getInstance("RSA");
    return kf.generatePrivate(
        new PKCS8EncodedKeySpec(Base64.getDecoder().decode(privateKey)));
  } catch (NoSuchAlgorithmException e) {
    throw new RuntimeException("當(dāng)前Java環(huán)境不支持RSA", e);
  } catch (InvalidKeySpecException e) {
    throw new RuntimeException("無(wú)效的密鑰格式");
  }
}
/**
* Read private key from file
*
* @param string    $filepath     PEM encoded private key file path
* 
* @return resource|bool     Private key resource identifier on success, or FALSE on error
*/
public static function getPrivateKey($filepath) {
    return openssl_get_privatekey(file_get_contents($filepath));
}
protected string sign(string message)
{
    // 需去除私鑰文件中的-----BEGIN/END PRIVATE KEY-----
    string privateKey = "MIIEvgIBADANBgkqhkiG...30HBe+GD1tntZgf6I1Y0ZpHZ";
    byte[] keyData = Convert.FromBase64String(privateKey);
    using (CngKey cngKey = CngKey.Import(keyData, CngKeyBlobFormat.Pkcs8PrivateBlob))
    using (RSACng rsa = new RSACng(cngKey))
    {
        byte[] data = System.Text.Encoding.UTF8.GetBytes(message);
        return Convert.ToBase64String(rsa.SignData(data, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1));
    }
}
package main
import (
  "crypto/x509"
  "encoding/pem"
  "fmt"
  "log"
)

func main() {
  var pemData = []byte(`
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC1yhh6LNB8nXmOSxdGKWmDh0OxAM/wnGyHKSD9tcEhMQTe+wabce0POXzejCmwFBzZa7ZmxH5LoAeyT7Fpwb7pptbbDx58CxCYhNEdQ2XrFILUCq3daMj++KQlyDp8U0NspFKsO57gSlihAJ49DzcXQb7Vs5daIvtLapIouPyixAE5uDL+afmJ+bXC11xP5sPWw1RfXynW3vbEyfRol9hQyQWfmO15GSZi6TTAhTKaW31yKaQNChy06K+LsE9JAU+ESxihthtGiMbY3fFRyhF9Ka2e0wIOz6UdcfwMjxXWRV4OLD1uFG9IYbUiugmYtDyIYZaFDPYdi/+Rjm10Ps5lAgMBAAECggEAb19kRZ2lEWOM8D9S//opGZrKPuvneVrsJpZtDuLG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NgQo0JLkuZ2Xk2Q8KhaNe+X8SYP9CFKIsXuhGrYI5ICjipov5oJqjESV4wle575eWwdPgF1ICabpIqdnX2MxS9tkk830uXxPrXpRA=
-----END PRIVATE KEY-----`)

  block, rest := pem.Decode(pemData)
  if block == nil || block.Type != "PRIVATE KEY" {
    log.Fatal("failed to decode PEM block containing public key")
  }

  pri, err := x509.ParsePKCS8PrivateKey(block.Bytes)
  if err != nil {
    log.Fatal(err)
  }

  fmt.Printf("Got a %T, with remaining data: %q", pri, rest)
}
Why is 401 Unauthorized Returned in the Request?

Please find the cause of the error and the corresponding solution in the table below according to the message.

Error description Cause Solution
The merchant has not set an APIv3 key. The merchant has not set an APIv3 key Please log in to the merchant platform to set an APIv3 key
The merchant has not applied for a certificate. The merchant has not applied for an API certificate Please refer to Private key and certificate
The merchant certificate serial number is incorrect. A wrong merchant certificate was used, or a merchant certificate that has expired was used, or the serial number of the obtained merchant certificate is incorrect. Please check the merchant certificate. You can log in to the merchant platform to view the correct certificate serial number.
The merchant certificate has expired. Expired merchant certificate and private key were used. Please log in to the merchant platform to renew the certificate for use.
The merchant certificate has been invalidated. The merchant certificate and private key invalidated by the merchant owner are used. Please log in to the merchant platform to apply for the certificate again, and use the new certificate.
Verification failed due to wrong signature. A wrong merchant private key was used, or the signature string was incorrectly constructed. See the next question.
Http header Authorization value format error The Authorization?header is missing, or its format is incorrect. Please check the Authorization?sent.
Http header Authorization authentication type is incorrect. The signature algorithm declared in Authorization?is not supported. Please check the Authorization?sent. Currently, it only supports WECHATPAY2-SHA256-RSA2048.
The timestamp in the Http header Authorization and the time for initiating the request must not exceed 5 minutes The time indicated by the timestamp in the Authorization?header is more than 5 minutes away from the current time. Please check whether the system time is accurate, or whether the logic for obtaining the time is correct.
The certificate has been replaced. Please use the new certificate. The merchant reapplied for a merchant API certificate. Please use the new merchant API certificate.
How to Locate the Error of"Verification Failed Due to Wrong Signature"?

In order to help developers locate the error, we will add the verification information to the error detail detail of the response when there is a verification failure. The verification information is a variety of information we request Constructing a signature stringbased on the merchant's HTTP.

1. Method, HTTP request method

2. Url, requested URL

3. Truncated_sign_message, the signature string used during WeChat Pay verification (the line break is displayed as \n). For easy viewing, we truncated the body of the final request message.

4. sign_message_length, byte length of the signature string used in WeChat Pay verification

{
"code": "SIGN_ERROR",
"message": "Verification failed due to wrong signature",
"detail": {
    "field": "signature",
    "issue": "sign not match",
    "location": "authorization",
    "sign_information": {
        "method": "GET",
        "url": "/payscore/user-service-state?service_id=500001&appid=wxeaf7bf1de621b0c2&openid=oWm9Z5JQwgV7BKAQUeKsUMVSjTpQ",
        "truncated_sign_message": "GET\n/payscore/user-service-state?service_id=500001&appid=wxeaf7bf1de621b0c2&openid=oWm9Z5JQwgV7BKAQUeKsUMVSjTpQ\n1559194069\n18a427e78d2344e1a71156a2690cc4d6\n\n",
        "sign_message_length": 157
    }
}
}

We recommend that developers export the signature string they have assembled and the byte length of the signature string in the debugging information in the program, and carefully compare the verification information returned by WeChat Pay to check for the following common errors:

No line break character added to the last line of the signature string

If the body of the request message is empty (such as a GET request), the last line should be a line break character.

The parameters in the signature string are inconsistent with the actual requested parameters.

The manually spliced URL is inconsistent with the actual request sent. We recommend using the HTTP library to construct the request object or URL object, then use the corresponding method to obtain the URL.

Two timestamps generated at different time were used when you sign and set the Authorization header.

Two different random strings generated at different time were used when you sign and set the Authorization header.

The JSON strings serialized at different time were used as the request subject during signing and request.

Notice
Developers of merchants can generate and save key parameters in variables, and use them for signing and sending requests to avoid inconsistencies in information generated at different time.

Inconsistent text encoding

The generated signature string uses non-UTF-8 encoding or no specific encoding is set.

Wrong signature string construction sequence

The signature string was not constructed in the order required by the document.

Wrong merchant private key

Developers can use the following openssl command to check whether the private key and the modulus (the product of the two large prime numbers p and q) in the merchant certificate are consistent. If yes, the private key and certificate are paired.

$ openssl x509 -noout -modulus -in 1900009191_20180326_cert.pem
Modulus=C6D43C87B991...
$ openssl rsa -noout -modulus -in 1900009191_20180326_key.pem
Modulus=C6D43C87B991...
Notice
1. The modulus length is 2048 bits, and the output is 512 bytes.
2. Before checking the key matching, please check the certificate serial number to check whether it is the correct merchant certificate.
Why is the Callback of WeChat Pay Missing Several HTTP Headers?

The callback of WeChat Pay contains the following four HTTP headers in the HTTP header:

1. Wechatpay-Timestamp

2. Wechatpay-Nonce

3. Wechatpay-Signature

4. Wechatpay-Serial

Some proxy servers or CDN service providers will "filter" the HTTP headers of WeChat Pay extensions when forwarding, causing the application layer of signature verification to fail to obtain the signature information of WeChat Pay. In that case, merchants should adjust the proxy server configuration or accept WeChat Pay callbacks through direct connection.


About  WeChat  Pay

Powered By Tencent & Tenpay Copyright©

2005-2024 Tenpay All Rights Reserved.

Contact Us
Wechat Pay Global

WeChat Pay Global

置頂