title: Python Websocket secure [SSL: CERTIFICATE_VERIFY_FAILED] (_ssl.c:777)
body: <p>I'm making a program that needs to receive real time messages from a WebSocket secure server.</p>
  
  <p>I tried doing this task using JavaScript and it works beautifully!<br>
  But JavaScript doesn't satisfy the needs of my project. So I'm trying to do the same thing in Python. But no success.</p>
  
  <p>The error I'm struggling to fix is:</p>
  
  <blockquote>
    <p>[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)</p>
  </blockquote>
  
  <p>I assume that JavaScript didn't have this problem because it uses the browser to certify the connection.</p>
  
  <p>What I'm using:</p>
  
  <ul>
  <li>Python 3.6.4</li>
  <li>Anaconda3</li>
  <li>Windows 10</li>
  </ul>
  
  <p>I really don't know what to do. I already searched a lot.<br>
  Can I solve this by changing the code?<br>
  Should I use another lib to make the connection?<br>
  Is the problem in Python or Anaconda?<br>
  Is it some newbie error that I can't figure out?</p>
  
  <p>Here's my Python code:</p>
  
  <pre><code>import websocket
  import websocket
  import threading
  import time
  
  def on_message(ws, message):
      print(message)
  
  def on_error(ws, error):
      print(error)
  
  def on_close(ws):
      print("### closed ###")
  
  def on_open(ws):
      def run(*args):
          for i in range(3):
              time.sleep(1)
              data = ws.recv()
              print(data)
          time.sleep(1)
          ws.close()
          print("thread terminating...")
      thread.start_new_thread(run, ())
  
  
  
  websocket.enableTrace(True)
  ws = websocket.WebSocketApp("wss://stream.binance.com:9443/ws/bnbbtc@ticker",
                              on_message = on_message,
                              on_error = on_error,
                              on_close = on_close)
  ws.on_open = on_open
  
  ws.run_forever()
  </code></pre>
  
  <p>If someone is interested, here is my JavaScript code:</p>
  
  <pre class="lang-js prettyprint-override"><code>var socket = new WebSocket('wss://hostname:port/dir/dir@ticker');
  
  socket.onopen = function(event) 
  {
      console.log('connected');
  }
  
  
  socket.onmessage = function(e){
     var server_message = e.data;
     console.log(server_message);
  }
  </code></pre>