title: Fail to validate URL in Facebook webhook subscription with python flask on the back end and ssl
body: <p>I'm trying to start using new messenger platform from FB.
  So i have server with name (i.e.)  www.mysite.com
  I got a valid SSL certificate for that domain and apache is setup correctly - all good.</p>
  
  <p>I have a python code on my server which runs flask and i point it to these certificates I got for the server:</p>
  
  <pre><code>from flask import Flask, request
  from pymessenger.bot import Bot
  import requests
  import ipdb
  from OpenSSL import SSL
  app = Flask(__name__)
  TOKEN = "&lt;access_token&gt;"
  bot = Bot(TOKEN)
  
  @app.route("/webhook", methods = ['GET', 'POST'])
  def hello():
      if request.method == 'GET':
          if (request.args.get("hub.verify_token") == "my_awesome_token"):
                  return request.args.get("hub.challenge")
      if request.method == 'POST':
          output = request.json
          event = output['entry'][0]['messaging']
          for x in event:
              if (x.get('message') and x['message'].get('text')):
                  message = x['message']['text']
                  recipient_id = x['sender']['id']
                  bot.send_text_message(recipient_id, message)
              else:
                  pass
          return "success"
  
  
  if __name__ == "__main__":
      # tried this - no luck
      #context = SSL.Context(SSL.SSLv23_METHOD)
      #context.use_privatekey_file('/home/mysite.com.key')
      #context.use_certificate_file('/home/intermediate.crt')
  
      # tried this - also same result
      context = ('/mysite.com.crt', '/mysite.com.key')
  
      app.run(host='www.mysite.com',port=5002, debug=True, ssl_context=context)
  </code></pre>
  
  <p>It starts without error and if I navigate with my browser - i see it gets connections.</p>
  
  <p><a href="https://i.stack.imgur.com/jrJOl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jrJOl.png" alt="enter image description here"></a></p>
  
  <p>port 5002 is open inf my firewall.</p>
  
  <p>But when I go to FB and try to subscribe to that URL - it keeps failing with this error:</p>
  
  <p><a href="https://i.stack.imgur.com/hSRqj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hSRqj.png" alt="enter image description here"></a></p>
  
  <pre><code>The URL couldn't be validated. 
  Callback verification failed with the following errors: curl_errno = 60;
  curl_error = SSL certificate problem: unable to get local issuer certificate;
  HTTP Status Code = 200; 
  HTTP Message = Connection established
  </code></pre>
  
  <p>I've read half the internet on the possible reasons and saw many different suggestions, but I can't make any of those work - i end up with the same result 95% of the time. 5% - some other error due to Flask bugging out with some "crazy" settings I try.</p>
  
  <p>What can be wrong? I'm using certificate files which I got from COMODO.
  Also tried in the call back url to use <code>/webhook</code> - no luck either. same error.</p>