Unable to connect to the Simple HTTPS Server
<p>I copied the code from below location:</p>

<p><strong><a href="https://www.piware.de/2011/01/creating-an-https-server-in-python/" rel="nofollow">https://www.piware.de/2011/01/creating-an-https-server-in-python/</a></strong></p>

<p>And created new pem file like below:</p>

<pre><code>sh-3.2# openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 10
Generating a 2048 bit RSA private key
.......................+++
...............................+++
writing new private key to 'key.pem'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:US
State or Province Name (full name) [Berkshire]:CA
Locality Name (eg, city) [Newbury]:CA
Organization Name (eg, company) [My Company Ltd]:Test
Organizational Unit Name (eg, section) []:Test
Common Name (eg, your name or your server's hostname) []:mybox.com
Email Address []:me@test.com
</code></pre>

<p>It created 2 files cert.pem and key.pem. So my final code was:</p>

<pre><code>import BaseHTTPServer, SimpleHTTPServer
import ssl

httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='/myhome/cert.pem', server_side=True)
httpd.serve_forever()
</code></pre>

<p>And I ran my program:</p>

<pre><code>python myserver.py
</code></pre>

<p>But when I try to access it from browser:</p>

<pre><code>https://mybox.com:4443 
</code></pre>

<p>I am unable to establish the connection but when I try like below:</p>

<pre><code>python -m SimpleHTTPServer 4443 
</code></pre>

<p>and then try to access via browser I get below error:</p>

<pre><code>An error occurred during a connection to mybox.com:4443. SSL received a record that exceeded the maximum permissible length. Error code: SSL_ERROR_RX_RECORD_TOO_LONG
</code></pre>

<p>I aim to make a simple HTTPS server. Please let me know how can I fix the issue?
======================= updates =================================</p>

<p>I copied the key.pem file to cert.pem</p>

<pre><code>cat key.pem &gt;&gt; cert.pem
</code></pre>

<p>Now when I bring up my server :</p>

<pre><code>python ./try.py
</code></pre>

<p>and Hit URL</p>

<pre><code>https://mybox.com:15368/
</code></pre>

<p>I see browser states "<strong>Connected to mybox.com:4443</strong>" but keeps waiting for a responding page. While at box I see below ouput:</p>

<pre><code># python try.py
Enter PEM pass phrase:
Enter PEM pass phrase:
Enter PEM pass phrase:
Enter PEM pass phrase:
Enter PEM pass phrase:
Enter PEM pass phrase:
Enter PEM pass phrase:
Enter PEM pass phrase:
Enter PEM pass phrase:
Enter PEM pass phrase:
Enter PEM pass phrase:
Enter PEM pass phrase:
</code></pre>

<p>I need to keep entering the same pass phrase which I used while creating the the cert and pem files</p>