• <legend id='Z0ekz'><style id='Z0ekz'><dir id='Z0ekz'><q id='Z0ekz'></q></dir></style></legend>

      <bdo id='Z0ekz'></bdo><ul id='Z0ekz'></ul>

    1. <small id='Z0ekz'></small><noframes id='Z0ekz'>

      <tfoot id='Z0ekz'></tfoot>

        <i id='Z0ekz'><tr id='Z0ekz'><dt id='Z0ekz'><q id='Z0ekz'><span id='Z0ekz'><b id='Z0ekz'><form id='Z0ekz'><ins id='Z0ekz'></ins><ul id='Z0ekz'></ul><sub id='Z0ekz'></sub></form><legend id='Z0ekz'></legend><bdo id='Z0ekz'><pre id='Z0ekz'><center id='Z0ekz'></center></pre></bdo></b><th id='Z0ekz'></th></span></q></dt></tr></i><div id='Z0ekz'><tfoot id='Z0ekz'></tfoot><dl id='Z0ekz'><fieldset id='Z0ekz'></fieldset></dl></div>

        Python请求-客户端证书的SSL错误

        Python Requests - SSL error for client side cert(Python请求-客户端证书的SSL错误)
          <tbody id='Kpshk'></tbody>

          1. <small id='Kpshk'></small><noframes id='Kpshk'>

              • <i id='Kpshk'><tr id='Kpshk'><dt id='Kpshk'><q id='Kpshk'><span id='Kpshk'><b id='Kpshk'><form id='Kpshk'><ins id='Kpshk'></ins><ul id='Kpshk'></ul><sub id='Kpshk'></sub></form><legend id='Kpshk'></legend><bdo id='Kpshk'><pre id='Kpshk'><center id='Kpshk'></center></pre></bdo></b><th id='Kpshk'></th></span></q></dt></tr></i><div id='Kpshk'><tfoot id='Kpshk'></tfoot><dl id='Kpshk'><fieldset id='Kpshk'></fieldset></dl></div>
                <tfoot id='Kpshk'></tfoot>
                  <bdo id='Kpshk'></bdo><ul id='Kpshk'></ul>
                  <legend id='Kpshk'><style id='Kpshk'><dir id='Kpshk'><q id='Kpshk'></q></dir></style></legend>

                  本文介绍了Python请求-客户端证书的SSL错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 python 中的请求调用 REST API,到目前为止,当我设置 verify=False 时已经成功.

                  I'm calling a REST API with requests in python and so far have been successful when I set verify=False.

                  现在,我必须使用需要导入的客户端证书进行身份验证,每次使用 cert (.pfx) 时都会收到此错误.cert.pfx 受密码保护.

                  Now, I have to use client side cert that I need to import for authentication and I'm getting this error everytime I'm using the cert (.pfx). cert.pfx is password protected.

                  r = requests.post(url, params=payload, headers=headers, 
                                    data=payload, verify='cert.pfx')
                  

                  这是我得到的错误:

                  Traceback (most recent call last):
                  File "C:UsersmeDesktop	est.py", line 65, in <module>
                  r = requests.post(url, params=payload, headers=headers, data=payload, verify=cafile)
                  File "C:Python33libsite-packages
                  equestsapi.py", line 88, in post
                  return request('post', url, data=data, **kwargs)
                  File "C:Python33libsite-packages
                  equestsapi.py", line 44, in request
                  return session.request(method=method, url=url, **kwargs)
                  File "C:Python33libsite-packages
                  equestssessions.py", line 346, in request
                  resp = self.send(prep, **send_kwargs)
                  File "C:Python33libsite-packages
                  equestssessions.py", line 449, in send
                  r = adapter.send(request, **kwargs)
                  File "C:Python33libsite-packages
                  equestsadapters.py", line 322, in send
                  raise SSLError(e)
                  requests.exceptions.SSLError: unknown error (_ssl.c:2158)
                  

                  我也尝试使用 openssl 获取 .pem 和密钥,但使用 .pem 并获取 SSL: CERTIFICATE_VERIFY_FAILED

                  I've also tried openssl to get .pem and key but with .pem and getting SSL: CERTIFICATE_VERIFY_FAILED

                  有人可以指导我如何导入证书以及将其放置在哪里吗?我尝试搜索,但仍然遇到同样的问题.

                  Can someone please direct me on how to import the certs and where to place it? I tried searching but still faced with the same issue.

                  推荐答案

                  我也遇到了同样的问题.verify 参数是指服务器的证书.您希望 cert 参数指定您的客户端证书.

                  I had this same problem. The verify parameter refers to the server's certificate. You want the cert parameter to specify your client certificate.

                  import requests
                  cert_file_path = "cert.pem"
                  key_file_path = "key.pem"
                  
                  url = "https://example.com/resource"
                  params = {"param_1": "value_1", "param_2": "value_2"}
                  cert = (cert_file_path, key_file_path)
                  r = requests.get(url, params=params, cert=cert)
                  

                  这篇关于Python请求-客户端证书的SSL错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What happens when you compare 2 pandas Series(当你比较 2 个 pandas 系列时会发生什么)
                  Quickly find differences between two large text files(快速查找两个大文本文件之间的差异)
                  Python - Compare 2 files and output differences(Python - 比较 2 个文件和输出差异)
                  Why do comparisions between very large float values fail in python?(为什么在 python 中非常大的浮点值之间的比较会失败?)
                  Dictionary merge by updating but not overwriting if value exists(字典通过更新合并,但如果值存在则不覆盖)
                  Find entries of one text file in another file in python(在python中的另一个文件中查找一个文本文件的条目)

                    • <small id='r4v5P'></small><noframes id='r4v5P'>

                      <i id='r4v5P'><tr id='r4v5P'><dt id='r4v5P'><q id='r4v5P'><span id='r4v5P'><b id='r4v5P'><form id='r4v5P'><ins id='r4v5P'></ins><ul id='r4v5P'></ul><sub id='r4v5P'></sub></form><legend id='r4v5P'></legend><bdo id='r4v5P'><pre id='r4v5P'><center id='r4v5P'></center></pre></bdo></b><th id='r4v5P'></th></span></q></dt></tr></i><div id='r4v5P'><tfoot id='r4v5P'></tfoot><dl id='r4v5P'><fieldset id='r4v5P'></fieldset></dl></div>

                        <bdo id='r4v5P'></bdo><ul id='r4v5P'></ul>

                            <tbody id='r4v5P'></tbody>
                        1. <legend id='r4v5P'><style id='r4v5P'><dir id='r4v5P'><q id='r4v5P'></q></dir></style></legend>
                            <tfoot id='r4v5P'></tfoot>