4

How do I keep my script running after encountering this error?

requests.exceptions.SSLError:
HTTPSConnectionPool(host='www.funcate.org.br', port=443): Max retries exceeded with url: /pt/portal-de-compras?file=../../../index.php%250A (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:718)'),))

Graham
  • 7,431
  • 18
  • 59
  • 84
Saulo Abrantes
  • 41
  • 1
  • 1
  • 2
  • 1
    [Editing](https://stackoverflow.com/posts/53123565/edit) your question to include a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) will help people help you. That said, you might just need a simple [`try`/`except`](https://stackoverflow.com/a/575711/3551604). – c-x-berger Nov 02 '18 at 17:59
  • ...well, `try`/`except` if you don't want the untrustable content. If you want to retrieve the content anyhow, that calls for a different solution. – Charles Duffy Nov 02 '18 at 19:51
  • ...also, are you really sure you want to *ignore* the error, as opposed to (f/e) embedding the certificate in your software so you can validate it, and thus avoiding the error without completely giving up the security that SSL is supposed to offer you? – Charles Duffy Nov 02 '18 at 19:52

1 Answers1

4

You can switch off SSL certificate verification by passing verify=False as an extra argument to the requests.get() function:

response = requests.get('https://foobar.com.br/', verify=False)

Be advised that this will make you susceptible to all sorts of man in the middle attacks. SSL certificates are used for a reason :-) Although I realize that you are not necessarily in a position to enforce this.

digitalarbeiter
  • 2,295
  • 14
  • 16
  • While this code snippet may solve the question, [including an explanation](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. – dpr Nov 02 '18 at 19:36
  • @dpr You're right of course. I gave in to the temptation of answering in style with the question. I shall edit my answer accordingly. – digitalarbeiter Nov 02 '18 at 19:44
  • 1
    When answering in style of the question you should have omitted the formatting – dpr Nov 02 '18 at 19:46