Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple HTTP Server SSL record_too_long error
    text
    copied!<p>I am trying to run a few Python CGI scripts using CGIHTTPServer. This works fine, but now I'd like to run using SSL on the Web listener.</p> <p>I started with the solution at <a href="http://code.activestate.com/recipes/442473-simple-http-server-supporting-ssl-secure-communica/" rel="nofollow">Activestate code recipes</a> and changed SimpleHTTPRequestHandler to CGIHTTPRequestHandler. This works fine serving static files, including the cgi scripts (cgi-bin is, for now, a link to ".") but for cgi scripts Firefox shows</p> <blockquote> <p>"SSL received a record that exceeded the maximum permissible length"</p> <p>Error code: ssl_error_rx_record_too_long.</p> </blockquote> <p>Web searches indicate this is likely a server issue, not browser, which seems logical to me. Also, I've tried all the suggested browser settings. I've tried a variety of server settings also, but no joy. </p> <ul> <li>Platform is RHEL 2.6.18</li> <li>Python is 2.4.3 - please don't suggest using "<code>import ssl</code>" as it isn't available</li> <li>Self signed certificate, accepted in browser (static files work)</li> </ul> <p>code:</p> <pre><code>import socket, sys import SocketServer import BaseHTTPServer import CGIHTTPServer from OpenSSL import SSL class SecureHTTPServer(BaseHTTPServer.HTTPServer): def __init__(self, server_address, HandlerClass): self.allow_reuse_address = True SockeServer.BaseServer.__init__(self, server_address, HandlerClass) ctx = SSL.Context(SSL.SSLv23_METHOD) ctx.use_privatekey_file ("path/key.pem") ctx.use_certificate_file("path/cert.pem") self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type)) self.server_bind() self.server_activate() class SecureHTTPRequestHandler(CGIHTTPServer.CGIHTTPRequestHandler): def setup(self): self.cgi_directories= ['cgi-bin'] self.connection = self.request self.rfile = socket._fileobject(self.request, "rb", self.rbufsize) self.wfile = socket._fileobject(self.request, "wb", self.wbufsize) def test(HandlerClass = SecureHTTPRequestHandler, ServerClass = SecureHTTPServer): httpd = ServerClass(('0.0.0.0',4443), HandlerClass) sa = httpd.socket.getsockname() print "Serving HTTPS on", sa[0], "port", sa[1], "..." httpd.serve_forever() if __name__ == '__main__': test() </code></pre> <p>How may I get this working for a quick and easy web interface in Python 2.4?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload