0

我一直在尝试按照此处列出的 stunnel 使用 django runserver 和 ssl 的说明进行操作:

如何像使用“runserver”的非 https 连接一样轻松地测试与 Django 的 https 连接?

但我遇到了一些麻烦。我有 stunnel 和两个运行服务器,每个都在虚拟环境中运行。每个人似乎都在自己工作。

stunnel.pem 看起来像这样:

-----BEGIN RSA PRIVATE KEY-----
(random)
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
(random)
-----END CERTIFICATE-----

dev_https 看起来像这样:

pid=

cert = stunnel/stunnel.pem
sslVersion = SSLv3
foreground = yes
output = stunnel.log

[https]
accept=8443
connect=8001
TIMEOUTclose=1

当我尝试访问

https://127.0.0.1:8443/ 

这是发生的事情:

Stunnel,执行:

stunnel4 dev_https

显示了这一点:

2012.08.23 20:20:58 LOG5[3818:140280034400000]: Service https accepted connection from 127.0.0.1:44302
2012.08.23 20:20:58 LOG5[3818:140280034400000]: connect_blocking: connected 127.0.0.1:8001
2012.08.23 20:20:58 LOG5[3818:140280034400000]: Service https connected remote server from 127.0.0.1:34622
2012.08.23 20:20:58 LOG5[3818:140280034400000]: Connection closed: 187 bytes sent to SSL, 422 bytes sent to socket

服务器执行:

python2.7 manage.py runserver

显示:

(nothing)

服务器执行:

HTTPS=1 python2.7 managpy runserver 8001

显示:

[23/Aug/2012 19:20:58] "GET / HTTP/1.1" 301 0

最后,浏览器中的网页请求显示标准 chrome 错误:

This webpage is not available
The server at 127.0.0.1 can't be found, because the DNS lookup failed.

我会很感激任何关于我可以改变什么或我做错了什么的建议。谢谢您的帮助!

更新 我现在收到此错误消息:

----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 52878)  
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 582, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line 139, in __init__
    super(WSGIRequestHandler, self).__init__(*args, **kwargs)
  File "/usr/lib/python2.7/SocketServer.py", line 638, in __init__
self.handle()
   File "/usr/lib/python2.7/wsgiref/simple_server.py", line 116, in handle
self.raw_requestline = self.rfile.readline()
  File "/usr/lib/python2.7/socket.py", line 447, in readline
data = self._sock.recv(self._rbufsize)
error: [Errno 104] Connection reset by peer
 ----------------------------------------
4

0 回答 0