我正在尝试连接到 Visa Direct API,但我没有通过基本的 SSL 证书认证,这是我的代码:
import requests
headers = { 'Content-Type' : 'Application/json' }
url = 'https://sandbox.visa.com/rsrv_vpp/v1/acnl'
payload = {"SystemsTraceAuditNumber":565690,
"RetrievalReferenceNumber":"505012455690",
"AcquiringBin":409999,
"AcquirerCountryCode":"840",
"PrimaryAccountNumber":"4895070000008881"}
r = requests.post(url, data=json.dumps(payload),
cert =('/etc/ssl/certs/sandbox_cert.pem'), headers=headers,
auth=('370df57a-a8aa-4446-a23e-44a0ef06ea09',
'6023e518-c36c-47a8-b16e-c8a5b3a941ef'))
屁股你可以看到我正在使用请求并将证书参数与 API 用户和密码信息一起传递,但我不断收到错误:
requests.exceptions.SSLError: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
最佳答案
当我尝试打开 https://sandbox.visa.com/rsrv_vpp/v1/acnl 时出现 SSL 错误在谷歌浏览器中。
签证文件说
- SSL Server Authentication
The SSL server certificate installed on sandbox.visa.com servers is a Visa issued self-signed certificate. Client applications need to add the sandbox.visa.com SSL certificate to their local trust store to prevent SSL Handshake errors at runtime.
Ensure that your application that connects to the Visa Direct API is configured (or built) to use the trusted certificate store as a trust store, and not a key store.
Verify that the application is configured to use the right password associated with the trust store file.
看来您需要先进行一些 SSL 身份验证,然后才能连接到 Visa。
关于Python/SSL 认证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29427376/