これで1日の良い部分を過ごしました。ウィットの終わり。 Python 2.6.6/2.7.2をインストールしたマシン "A"と、Python 2.6.7/2.7.2をインストールしたマシン "B"があります。Urllib.urlopen()は、1台のマシンでPython 2.6.6とSSLv3 urlで動作しますが、別のマシンでは2.6.7/2.7.2で動作しません
マシンAでは、urllib2.urlopen('https://fed.princeton.edu')
でSSLv3で暗号化されたWebサイトを取得できますが、Python 2.6.6では2.7.2では使用できません。
マシンBで、どちらのPythonバージョンを使用してもWebサイトを取得できません。
得ることができないことで、私はエラーを取得することを意味:
Traceback:
File "/usr/local/lib/python2.7/dist-packages/Django-1.3.1-py2.7.egg/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django_cas-2.0.3-py2.7.egg/django_cas/views.py" in login
78. user = auth.authenticate(ticket=ticket, service=service)
File "/usr/local/lib/python2.7/dist-packages/Django-1.3.1-py2.7.egg/django/contrib/auth/__init__.py" in authenticate
55. user = backend.authenticate(**credentials)
File "/usr/local/lib/python2.7/dist-packages/django_cas-2.0.3-py2.7.egg/django_cas/backends.py" in authenticate
72. username = _verify(ticket, service)
File "/usr/local/lib/python2.7/dist-packages/django_cas-2.0.3-py2.7.egg/django_cas/backends.py" in _verify_cas2
46. page = urlopen(url)
File "/usr/lib/python2.7/urllib.py" in urlopen
84. return opener.open(url)
File "/usr/lib/python2.7/urllib.py" in open
205. return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py" in open_https
435. h.endheaders(data)
File "/usr/lib/python2.7/httplib.py" in endheaders
954. self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py" in _send_output
814. self.send(msg)
File "/usr/lib/python2.7/httplib.py" in send
776. self.connect()
File "/usr/lib/python2.7/httplib.py" in connect
1161. self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
File "/usr/lib/python2.7/ssl.py" in wrap_socket
372. ciphers=ciphers)
File "/usr/lib/python2.7/ssl.py" in __init__
134. self.do_handshake()
File "/usr/lib/python2.7/ssl.py" in do_handshake
296. self._sslobj.do_handshake()
Exception Type: IOError at /login
Exception Value: [Errno socket error] [Errno 1] _ssl.c:503: error:140773F2:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert unexpected message
まず、私は以前のPythonのバージョンで動作何かがマシンA上で、後に動作しないことに困惑しています2.6.6で動作するものが2.6.7でも動作しないことは非常に混乱しています(異なるマシンではあるが)。これはなぜでしょうか?
ここでは、Pythonの設定が両方で同じであることはわかりませんが、とimport httplib; httplib.HTTPSConnection
は両方のマシンのすべてのバージョンで機能します。私は両方のマシンでcurl -v https://fed.princeton.edu
とopenssl fed.princeton.edu:https
を試してみましたが、これらのコマンドはすべて動作します。
また、著者はlibCurlのurllibをあきらめたように見えるHow to use urllib2 to get a webpage using SSLv3 encryptionを見つけました(私はむしろurllibを使用するdjango-casを使っているので、私は欲しくないそのコードをあまりにも冗長にする)。
注:私はちょうどhttp://bugs.python.org/issue11220を見つけ、そして最後のポストのソリューションは、私がウェブサイトを開くurlopen使用することができます。しかし、私はどのように彼らの解決策(urllib2.install_opener(urllib2.build_opener(HTTPSHandlerV3()))
?を使用しているようです)を使用してdjango-casの私のurlopen()を解決することができますか?
2つのシステムに異なるバージョンのOpenSSLがありますか? – larsks