I am connecting to a remote mysql database (on my local network) from a flask app using ssl connection.
app.config['SQLALCHEMY_DATABASE_URI'] = "mysql+pymysql://user:password@192.168.1.24/AwesomeDB?ssl_ca=client-ssl/ca.pem&ssl_cert=client-ssl/client-cert.pem&ssl_key=client-ssl/client-key.pem"
Any call to the database throws this mysterious error.
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on '192.168.1.24' ([SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: IP address mismatch, certificate is not valid for '192.168.1.24'. (_ssl.c:1122))")
I can log into the mysql monitor from terminal just fine.
mysql -u user -p -h 192.168.1.24 --ssl-ca=client-ssl/ca.pem --ssl-cert=client-ssl/client-cert.pem --ssl-key=client-ssl/client-key.pem
I am on macos 11.0.1 and python 3.9.0.
I have tried installing and linking certifi
as described here. Everything works fine without ssl. Please help.
Edit: the problem is not specific to macos, I tried connecting from ubuntu with the same result.