facebook graph api 报错SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)')

使用facebook graph api,报错如下

一开始以为是https证书验证失败,查了一下午源码,没有看到问题,于是把Python27\lib\site-packages\requests\adapters.py文件的如下位置异常处理注释掉了,看看异常到底从哪来的

    def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None):
        """Sends PreparedRequest object. Returns Response object.

        :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
        :param stream: (optional) Whether to stream the request content.
        :param timeout: (optional) How long to wait for the server to send
            data before giving up, as a float, or a :ref:`(connect timeout,
            read timeout) <timeouts>` tuple.
        :type timeout: float or tuple or urllib3 Timeout object
        :param verify: (optional) Either a boolean, in which case it controls whether
            we verify the server‘s TLS certificate, or a string, in which case it
            must be a path to a CA bundle to use
        :param cert: (optional) Any user-provided SSL certificate to be trusted.
        :param proxies: (optional) The proxies dictionary to apply to the request.
        :rtype: requests.Response
        """

        conn = self.get_connection(request.url, proxies)

        self.cert_verify(conn, request.url, verify, cert)
        url = self.request_url(request, proxies)
        self.add_headers(request)

        chunked = not (request.body is None or ‘Content-Length‘ in request.headers)

        if isinstance(timeout, tuple):
            try:
                connect, read = timeout
                timeout = TimeoutSauce(connect=connect, read=read)
            except ValueError as e:
                # this may raise a string formatting error.
                err = ("Invalid timeout {0}. Pass a (connect, read) "
                       "timeout tuple, or a single float to set "
                       "both timeouts to the same value".format(timeout))
                raise ValueError(err)
        elif isinstance(timeout, TimeoutSauce):
            pass
        else:
            timeout = TimeoutSauce(connect=timeout, read=timeout)

        try:
            if not chunked:
                resp = conn.urlopen(
                    method=request.method,
                    url=url,
                    body=request.body,
                    headers=request.headers,
                    redirect=False,
                    assert_same_host=False,
                    preload_content=False,
                    decode_content=False,
                    retries=self.max_retries,
                    timeout=timeout
                )

            # Send the request.
            else:
                if hasattr(conn, ‘proxy_pool‘):
                    conn = conn.proxy_pool

                low_conn = conn._get_conn(timeout=DEFAULT_POOL_TIMEOUT)

                try:
                    low_conn.putrequest(request.method,
                                        url,
                                        skip_accept_encoding=True)

                    for header, value in request.headers.items():
                        low_conn.putheader(header, value)

                    low_conn.endheaders()

                    for i in request.body:
                        low_conn.send(hex(len(i))[2:].encode(‘utf-8‘))
                        low_conn.send(b‘\r\n‘)
                        low_conn.send(i)
                        low_conn.send(b‘\r\n‘)
                    low_conn.send(b‘0\r\n\r\n‘)

                    # Receive the response from the server
                    try:
                        # For Python 2.7+ versions, use buffering of HTTP
                        # responses
                        r = low_conn.getresponse(buffering=True)
                    except TypeError:
                        # For compatibility with Python 2.6 versions and back
                        r = low_conn.getresponse()

                    resp = HTTPResponse.from_httplib(
                        r,
                        pool=conn,
                        connection=low_conn,
                        preload_content=False,
                        decode_content=False
                    )
                except:
                    # If we hit any problems here, clean up the connection.
                    # Then, reraise so that we can handle the actual exception.
                    low_conn.close()
                    raise

        except (ProtocolError, socket.error) as err:
            raise ConnectionError(err, request=request)

        except MaxRetryError as e:
            if isinstance(e.reason, ConnectTimeoutError):
                # TODO: Remove this in 3.0.0: see #2811
                if not isinstance(e.reason, NewConnectionError):
                    raise ConnectTimeout(e, request=request)

            if isinstance(e.reason, ResponseError):
                raise RetryError(e, request=request)

            if isinstance(e.reason, _ProxyError):
                raise ProxyError(e, request=request)

            raise ConnectionError(e, request=request)

        except ClosedPoolError as e:
            raise ConnectionError(e, request=request)

        except _ProxyError as e:
            raise ProxyError(e)

       # except (_SSLError, _HTTPError) as e:
       #     if isinstance(e, _SSLError):
       #         raise SSLError(e, request=request)
       #     elif isinstance(e, ReadTimeoutError):
       #         raise ReadTimeout(e, request=request)
       #     else:
       #         raise

        return self.build_response(request, resp)

注释后报错

于是把Python27\lib\site-packages\urllib3\connectionpool.py625到630行注释掉

报错

最后估计是proxy的问题,找了一个墙外的服务器试一下果然好了,不FQ就办不成事,shit

祝病魔早日战胜方校长

facebook graph api 报错SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)')

时间: 2024-10-05 05:05:55

facebook graph api 报错SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)')的相关文章

ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)

/******************************************************************************* * ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847) * 说明: * 在处理HTTPS请求的时候出现ssl报错,之前貌似没这个问题. * * 2018-12-14 深圳 宝安西乡 曾剑锋 **************

open-falcon 安装Dashboard时候报错&quot;SSLError: The read operation timed out&quot;

在部署open-falcon环境过程中,安装Dashboard时候报错"SSLError: The read operation timed out".如下: [[email protected] dashboard]# ./env/bin/pip install -r pip_requirements.txt Downloading/unpacking Flask==0.10.1 (from -r pip_requirements.txt (line 1)) Downloading

Tomcat启动报错[org.apache.struts2.dispatcher.Dispatcher]Dispatcher initialization failed

Tomcat启动报错: [org.apache.struts2.dispatcher.Dispatcher]Dispatcher initialization failed Unable to load configuration. - bean - jar:file:/E:/SoftwareDevelopment/Software/Eclipse4.3/eclipse-jee-kepler-SR1-win32-x86_64/Workspace/.metadata/.plugins/org.ec

thinkphp5访问报错 ...with message &#39;mkdir(): Permission denied&#39; in... 或...failed to open stream: Permission denied&#39; in...

报错截图1: 报错截图2: 报错原因没有权限访问thinkphp5/runtime目录. 解决方法: 1.如果thinkphp5/runtime目录下面有文件,先清空thinkphp5/runtime目录: 2.修改thinkphp5/runtime目录权限为可读可写. thinkphp5访问报错 ...with message 'mkdir(): Permission denied' in... 或...failed to open stream: Permission denied' in.

MySQL root密码重置 报错:mysqladmin: connect to server at &#39;localhost&#39; failed的解决方案

===========================================================二,忘记本地root的登录密码解决过程:1.编辑/mysql/my.ini在[mysqld] 配置部分添加一行skip-grant-tables 2.保存后重启mysql[[email protected] etc]# service mysqld restartShutting down MySQL.                                      

MySQL 设置root密码报错:mysqladmin: connect to server at &#39;localhost&#39; failed

MySQL 设置root密码报错:mysqladmin: connect to server at 'localhost' failed 1.安装完MySQL设置root密码报错如下 [root@vm172-31-0-6 data]# mysqladmin -uroot password "linux@123" mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root

in `connect&#39;: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)

最近在用ruby的一些库的时候,总是出现这个错误. 在使用net/imap库的时候,或者net/http库(主要是用到了https,https是用了ssl) 的时候,具体如下: 错误提示:E:/Ruby200/lib/ruby/2.0.0/net/imap.rb:1454:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (Op

Rails 之微信开发 : OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

微信公众平台,使用Ruby On Rails + Win7 在取得OpenID时,如果简单的使用http.get方法,会出现如下 SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed 解决方案: def get_open_id code    url="https://api.weixin.qq.com/sns/oauth2/access_token?appi

关于livy的 java api 报错org.apache.livy.shaded.kryo.kryo.KryoException: Unable to find class: com.xxx.wordcount.WordCountJavaSpark

Livy Java api 依赖 <dependency> <groupId>org.apache.livy</groupId> <artifactId>livy-client-http</artifactId> <version>0.5.0-incubating</version> </dependency> <dependency> <groupId>org.apache.spark