cohaolain / ryanair-py

This is an open source Python module which allows you to retrieve the cheapest flights, with or without return flights, within a given set of dates.
https://github.com/cohaolain/ryanair-py
MIT License
51 stars 15 forks source link

CERTIFICATE_VERIFY_FAILED #12

Closed ati666 closed 10 months ago

ati666 commented 1 year ago

Why do I get CERTIFICATE_VERIFY_FAILED error?

requests.exceptions.SSLError: HTTPSConnectionPool(host='www.ryanair.com', port=443): Max retries exceeded with url: /hu/hu (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)')))

All my code was just the initalization:

'from ryanair import Ryanair

# You can set a currency at the API instance level, so could also be GBP etc. also.
# Note that this may not *always* be respected by the API, so always check the currency returned matches
# your expectation.
api = Ryanair("EUR")'
cohaolain commented 1 year ago

If you do something like

import requests

requests.get("https://example.com")

do you get a similar error?

If so, you're probably behind a proxy that's signing with its own cert. The library requests uses certs from certifi, rather than the system certs, so it won't necessarily see the proxy's own cert as valid, even if the system generally does.

You can override this behaviour of you want your traffic to trust this intermediate cert. In Windows you can override this by with something like the pip-system-certs package. On Linux, you can set an environment variable pointing either/both requests and urllib at the system ca certs.

ati666 commented 1 year ago

Thanks! I Think my VPN was the root-cause of this issue as I now I don't get that error.

from datetime import datetime, timedelta
from ryanair import Ryanair

api = Ryanair(currency="EUR")  # Euro currency, so could also be GBP etc. also
tomorrow = datetime.today().date() + timedelta(days=1)

flights = api.get_cheapest_flights("DUB", "2023-09-22", "2023-09-23")

and for this I'm getting

  File "C:\Users\user\PycharmProjects\flypy\venv\lib\site-packages\backoff\_common.py", line 29, in _init_wait_gen
    initialized = wait_gen(**kwargs)
TypeError: 'staticmethod' object is not callable

do you have any idea whats wrong?

cohaolain commented 1 year ago

What version of python are you on? I don't seem to be getting this when running the sample you provided.

cohaolain commented 10 months ago

Please see https://github.com/cohaolain/ryanair-py/issues/13 for updates on your TypeError: 'staticmethod' object is not callable issue.