I am trying to connect to a Cloud SQL instance running MySQL using SSL and Flask-SQLAlchemy. Here are the steps I've followed:
127.0.0.1:3306
using the Cloud SQL Auth Proxy just finecurrent_app.config['SQLALCHEMY_POOL_RECYCLE'] = 280
current_app.config['SQLALCHEMY_POOL_TIMEOUT'] = 20
current_app.config['SQLALCHEMY_ENGINE_OPTIONS'] = {
'connect_args': {
'ssl': {
'cert': '~/AppData/Local/Google/Cloud SDK/Projects/SIF/certs/client-cert.pem',
'key': '~/AppData/Local/Google/Cloud SDK/Projects/SIF/certs/client-key.pem',
'ca': '~/AppData/Local/Google/Cloud SDK/Projects/SIF/certs/server-ca.pem'
}
}
}
Now, whenever I try to open a connection, I get the error Lost connection to MySQL server during query
What am I doing wrong here?
Side question: Do I even need to try to configure SSL when connecting to the DB from within App Engine?
If you are connecting via the Cloud SQL Auth Proxy, client SSL certificates are not required nor supported. The proxy handles authentication and encryption with Cloud SQL. If you add SSL certificates to connect to the proxy, the connection will fail as the proxy is not expecting that connection type.