2014-05-08 20 views
0

我試圖與分裂力的SSLv3或TLSV1在分裂

from splinter import Browser 

browser = Browser() 
browser.visit('https://gateway.playneverwinter.com') 

if browser.is_text_present('Neverwinter'): 
    print("Yes, we made it to the entrance of the Prime Material Plane!") 
else: 
    print("Fumble") 

browser.quit() 

它無法訪問gateway.playneverwinter.com

File "gateway_bot.py", line 10, in <module> 
    browser.visit('https://gateway.playneverwinter.com') 
    File "/usr/local/lib/python3.4/dist-packages/splinter/driver/webdriver/__init__.py", line 53, in visit 
    self.connect(url) 
    File "/usr/local/lib/python3.4/dist-packages/splinter/request_handler/request_handler.py", line 23, in connect 
    self._create_connection() 
    File "/usr/local/lib/python3.4/dist-packages/splinter/request_handler/request_handler.py", line 53, in _create_connection 
    self.conn.endheaders() 
    File "/usr/lib/python3.4/http/client.py", line 1061, in endheaders 
    self._send_output(message_body) 
    File "/usr/lib/python3.4/http/client.py", line 906, in _send_output 
    self.send(msg) 
    File "/usr/lib/python3.4/http/client.py", line 841, in send 
    self.connect() 
    File "/usr/lib/python3.4/http/client.py", line 1205, in connect 
    server_hostname=server_hostname) 
    File "/usr/lib/python3.4/ssl.py", line 364, in wrap_socket 
    _context=self) 
    File "/usr/lib/python3.4/ssl.py", line 578, in __init__ 
    self.do_handshake() 
    File "/usr/lib/python3.4/ssl.py", line 805, in do_handshake 
    self._sslobj.do_handshake() 
    ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:598) 

Firefox是能夠沒有問題連接並瀏覽這個網站,堅韌。一些診斷

$ openssl s_client -connect gateway.playneverwinter.com:443    
CONNECTED(00000003) 
139745006343840:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:177: 

後,我發現,它看起來像a fixed issue in OpenSSL和強迫或者在SSLv3或使用TLSv1允許我連接(和我可以再下載與捲曲的目標),例如任

openssl s_client -ssl3 -connect gateway.playneverwinter.com:443 
openssl s_client -tls1 -connect gateway.playneverwinter.com:443 

根據OpenSSL的票的意見,我想到的是,問題是在服務器端,但我沒有訪問它,它是相當無益。因此,爲了快速修復,是否有強制使用SSLv3或TLSv1的方式?

+0

@Natecat複製粘貼失敗迫使SSLv3的,謝謝。 {{固定}} – Evpok

回答

0

繼@Natecat建議,我寫了一個猴子修補程序時出現此錯誤時

# Monkey patch splinter to force SSLv3 on `ssl.SSLEOFError` 
from splinter import request_handler 
import ssl 
from http import client as http_client 
_old_req = request_handler.request_handler.RequestHandler._create_connection 
def _splinter_sslv3_patch(self): 
    try: 
     _old_req(self) 
    except ssl.SSLEOFError: 
     self.conn = http_client.HTTPSConnection(self.host, self.port, 
               context=ssl.SSLContext(ssl.PROTOCOL_SSLv3)) 
     self.conn.putrequest('GET', self.path) 
     self.conn.putheader('User-agent', 'python/splinter') 
     if self.auth: 
      self.conn.putheader("Authorization", "Basic %s" % self.auth) 
     self.conn.endheaders() 
request_handler.request_handler.RequestHandler._create_connection = _splinter_sslv3_patch 
0

看過之後,我能想到的唯一方法就是進入該client.py文件並更改其ssl內容的初始化。