首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

Python3 httplib2连接https的有关问题

2013-01-01 
Python3 httplib2连接https的问题我现在是使用Python3, 本来是想用httplib2来代替urllib.request的...结果

Python3 httplib2连接https的问题
我现在是使用Python3, 本来是想用httplib2来代替urllib.request的...
结果httplib2连接https链接的时候报错,错误信息在最下面,看了一下httplib2的官方文档里面是这么说的
Features
HTTP and HTTPS
HTTPS support is only available if the socket module was compiled with SSL support.

这里我有一个疑问句子中所说的socket module was compiled with SSL support是指Python3的socket么?
或者换句话说编译Python3的时候要指定附加SSL选项之类什么的?
求指点


    conn.connect()
  File "C:\Python32\lib\http\client.py", line 1108, in connect
    server_hostname=server_hostname)
  File "C:\Python32\lib\ssl.py", line 189, in wrap_socket
    _context=self)
  File "C:\Python32\lib\ssl.py", line 276, in __init__
    raise x
  File "C:\Python32\lib\ssl.py", line 272, in __init__
    self.do_handshake()
  File "C:\Python32\lib\ssl.py", line 451, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [Errno 1] _ssl.c:392: error:14090086:SSL routines:SSL3_GET_SERVER_
CERTIFICATE:certificate verify failed


[解决办法]
貌似可以吧:

Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> 
>>> import http.client
>>> conn = http.client.HTTPSConnection('192.168.100.110', 443)
>>> conn.request("GET", "/index.html")
>>> r1 = conn.getresponse()
>>> print(r1.status, r1.reason)
200 OK
>>> data1 = r1.read()
>>> print(data1)
b'<html><body><h1>It works!</h1>\n<p>This is the default web page for this server.</p>\n<p>The web server software is running but no content has been added, yet.</p>\n</body></html>\n'
>>> 

[解决办法]
编译时ssl模块没有编译被忽略了.
[解决办法]
安装的标准版貌似有啊
[解决办法]
你没装libssl,怎么安python也没用。

热点排行