Python Requests: SSL Certificate Validation: CERTIFICATE_VERIFY_FAILED] (_ssl.c: 547)

I am trying to log in and clean up an airline site using the python request package. I get the error below by simply loading the main site. This code is used to work last year, but I still have not tried it with new 2.2.1 queries. Any ideas what is going on?

[SSL: CERTIFICATE_VERIFY_FAILED] certificate verification completed (_ssl.c: 547)

I am using queries 2.2.1.

ssladapter.py

from requests.adapters import HTTPAdapter
from requests.packages.urllib3.poolmanager import PoolManager

from ssl import PROTOCOL_TLSv1


class SSLAdapter(HTTPAdapter):
    '''An HTTPS Transport Adapter that uses an arbitrary SSL version.'''

    __attrs__ = ['max_retries', 'config', '_pool_connections', '_pool_maxsize', '_pool_block', 'ssl_version']

def __init__(self, ssl_version=None, **kwargs):
    self.ssl_version = ssl_version

    super(SSLAdapter, self).__init__(**kwargs)


def init_poolmanager(self, connections, maxsize, block=False):
    self.poolmanager = PoolManager(num_pools=connections,
        maxsize=maxsize, block = block,
        ssl_version=self.ssl_version)

scrape.py

import requests
import ssladapter
from ssl import PROTOCOL_TLSv1

session = requests.Session()
session.mount('https://', ssladapter.SSLAdapter(ssl_version=PROTOCOL_TLSv1))

request = session.get("www.delta.com")

!!! SSLERROR is here.

+4
source share
1 answer

This error is not a problem of the Requests library because it has been thoroughly tested.

This is a sign of a "Man-in-the-middle" attack .

, Sniffing, Fiddler Wireshark.

, SSL.

+1

Source: https://habr.com/ru/post/1533831/


All Articles