title: Python ssl server reporting TLSV1_ALERT_UNKNOWN_CA
body: <p>I have a Python SSL server that uses a self-signed certificate. I start my server like this:</p>
  <pre class="lang-py prettyprint-override"><code>httpd = BaseHTTPServer.HTTPServer(('', 443), MyHTTPHandler)
  httpd.socket = ssl.wrap_socket (httpd.socket, certfile='server.pem', server_side=True, cert_reqs=0)
  httpd.serve_forever()
  </code></pre>
  <p>I get the following error when I connect using Firefox:</p>
  <pre><code>----------------------------------------
  Exception happened during processing of request from ('127.0.0.1', 51194)
  Traceback (most recent call last):
    File &quot;/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py&quot;, line 295, in _handle_request_noblock
      self.process_request(request, client_address)
    File &quot;/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py&quot;, line 321, in process_request
      self.finish_request(request, client_address)
    File &quot;/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py&quot;, line 334, in finish_request
      self.RequestHandlerClass(request, client_address, self)
    File &quot;/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py&quot;, line 655, in __init__
      self.handle()
    File &quot;/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py&quot;, line 340, in handle
      self.handle_one_request()
    File &quot;/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py&quot;, line 310, in handle_one_request
      self.raw_requestline = self.rfile.readline(65537)
    File &quot;/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py&quot;, line 480, in readline
      data = self._sock.recv(self._rbufsize)
    File &quot;/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py&quot;, line 734, in recv
      return self.read(buflen)
    File &quot;/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py&quot;, line 621, in read
      v = self._sslobj.read(len or 1024)
  SSLError: [SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:1751)
  ----------------------------------------
  </code></pre>
  <p>I do not see this behavior with Chrome or another client. It only happens on the first connection (complaints about certificate) until I accept the certificate. The exception actually does not cause the program to quit.</p>
  <p>Why am I getting an error on the server? How can I avoid the exception?</p>