Google App Engine本地开发服务器上的SSLError

2 投票
1 回答
1213 浏览
提问于 2025-04-17 01:28

当我在App Engine上使用boto库时,出现了以下错误:

Traceback (most recent call last):
  File "C:\Program Files\Google\google_appengine\google\appengine\ext\webapp\_webapp25.py", line 701, in __call__
    handler.get(*groups)
  File "E:\Probes\pruebas\pruebasAWS\main.py", line 26, in get
    conn = S3Connection('<KEY1>','<KEY2>')
  File "E:\Probes\pruebas\pruebasAWS\boto\s3\connection.py", line 148, in __init__
    path=path, provider=provider)
  File "E:\Probes\pruebas\pruebasAWS\boto\connection.py", line 231, in __init__
    self.http_unretryable_exceptions.append(ssl.SSLError)
AttributeError: 'module' object has no attribute 'SSLError'

我已经安装了OpenSSL和Python 2.7。OpenSSL和Python的SSL库都在运行,当我把应用部署到谷歌的基础设施上时,一切正常。但是,当我在本地机器上执行这个应用时,就出现了问题。

代码如下:

from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from boto.s3.connection import S3Connection
import hashlib


class MainHandler(webapp.RequestHandler):
    def get(self):
        conn = S3Connection('<KEY1>','<KEY2>')
        bucket = conn.create_bucket(hashlib.md5('noTRePeaTedBuCket').hexdigest()+"probe")
        if bucket:
            self.response.out.write('Bucket creado')
        else:
            self.response.out.write('Bucket NO creado')

1 个回答

2

这里的实际问题是,AppEngine对一些东西进行了处理,导致我们无法导入某些标准的、内置的Python模块,比如ssl模块。

在boto的IRC聊天中,有人讨论过这个问题,其中一位用户提出了一个补丁:

https://github.com/samba/boto/commit/6f1ab73d92ff6fb2589362bbdadf6bbe66811e7e

这种形式的补丁可能很快会被合并到boto的主版本中。

撰写回答