0

As I mentioned in the title, I want to read the source code of a website. Everything is working fine, but sometimes I get an Error.

Error

urllib2.URLError: <urlopen error [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:590)

I know that there is a problem with the ssl certificate, but I don't know how to fix it. I already spent several hours to find a solution to my problem, but until now I was not successful (I have already tried a couple things with the ssl module).

The way I do it:

import urllib2
urllib2.openurl("https://www.website.com")

If there is no way doing this kind of stuff with urllib2, is there a different module, which you recommend?

ghnome
  • 57
  • 1
  • 7
  • PS: I am using python2.7.10 – ghnome Dec 28 '16 at 21:57
  • Handshake failure might be anything like missing SNI or an old OpenSSL version which does not support newer protocols or ciphers. You might try requests library which depending on the unknown cause of the problem might work better or fail too. If this does not help provide information about platform, OpenSSL version (`ssl.OPENSSL_VERSION`) and target URL so that others can reproduce the problem and help you. – Steffen Ullrich Dec 28 '16 at 22:01
  • 'OpenSSL 0.9.8zh 14 Jan 2016' – ghnome Dec 28 '16 at 22:05
  • Since the target URL is still unknown my guess is that it requires either ciphers like ECDHE and/or protocol versions like TLS 1.2 which are not available in this obsolete OpenSSL version. You might check with [ssllabs](https://www.ssllabs.com/ssltest/analyze.html). In this case upgrade everything to use a newer OpenSSL. – Steffen Ullrich Dec 28 '16 at 22:07
  • Website: bs.to! – ghnome Dec 28 '16 at 22:08
  • Can you do something with the URL? – ghnome Dec 28 '16 at 22:14
  • Any idea what I am doing wrong? – ghnome Dec 28 '16 at 22:27
  • My guess this is related to SNI which is required by this target. See also http://stackoverflow.com/questions/30918761/sslv3-alert-handshake-failure-with-urllib2. – Steffen Ullrich Dec 29 '16 at 05:55

1 Answers1

0

It might be happening due to some ssl options that the server requests and urllib2 library doesn't support.

I recommend you to install and use request library as it provides more security packages and options.

Aliweb
  • 1,891
  • 3
  • 21
  • 44