Python/SSL 认证

标签 python ssl request

我正在尝试连接到 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 错误在谷歌浏览器中。

签证文件说

  1. 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/

相关文章:

python - 使用 Jinja 遍历项目,在每第 5 个项目后添加 div

windows - Windows 服务上托管的 WCF 服务的 SSL 证书

.htaccess - htaccess 将子目录的 http 重定向到 https

spring-boot - 在 spring boot 中禁用 CSRF 的原因

python - sympy 微分方程组 : Not Implemented

python - 将数组转换为字符串

python - 用于寻址异步请求的 ZMQ Python 请求回复代理

php - 如何 $_REQUEST 数据库创建的选项?

javascript - Node Jquery 抓取问题

python - 如何在 PyQt 中的 QGraphicsView 旁边添加菜单栏(QMainWindow)?