Set up SSL between Google Cloud and Cloud SQL

I've got a WordPress site on GCP Compute Engine and a database which is hosted on Cloud SQL, which works great. My only issue is every time I select "Allow only SSL connections" on the GCP dashboard the site can't connect to the database and I get "Error connecting to database" error.

I have downloaded all the SSL (.pem) files that Google provided when creating the SQL instance. Have followed instructions by John Hanley https://github.com/jhanley-com/wordpress-cloud-sql, as soon as I turn SSL on and it still breaks.

I also have Comodo SSL for the site and Cloudflare setup, unsure if that has anything to do with it.

Have also been looking at Cloud SQL Proxy but unsure how to set that up or if it's better or worse than the above solution...

Have been instructed by John Hanley to create a new question so he can assist.

Thanks in advance.

Solutions

When you create a new client certificate [1] the three files you are asked to download (server-ca.pem, client-cert.pem, client-key.pem) are the values for the --ssl-ca, --ssl-cert, and --ssl-key command options

E.g: mysql --ssl-ca=server-ca.pem --ssl-cert=client-cert.pem --ssl-key=client-key.pem --host=[instance-ip] --user=root --password

If it cannot find them you will receive errors such as: SSL connection error: SSL_CTX_set_default_verify_paths failed error.

Those files will have to be present in the VM directory the command is being run for the Instance to verify the credentials to connect. Remember to have Only secured connection (SSL connection) activated for it to work.

Bear in mind that the Compute Engine instance should be in the same region with your Cloud SQL instance. Please proceed and try this example, in order to eliminate the possibility of misconfiguration[1].

If you still get error, tell us how how did you enforce the SSL connections? Looks like follow Google’s documentation about it [2], right? If so, did you do it through the console, gcloud command or cURL?

About the Cloud SQL Proxy [3] is an option to access your Cloud SQL Second Generation instances without having to whitelist IP addresses or configure SSL.

Sincerely,

[1] - https://cloud.google.com/sql/docs/mysql/connect-compute-engine [2] - https://cloud.google.com/sql/docs/mysql/configure-ssl-instance#enforcing-ssl [3] - https://cloud.google.com/sql/docs/mysql/connect-compute-engine#gce-connect-proxy

Similar questions

Connection Active Google Cloud SQL
I have setup wordpress on Google Cloud SQL and Google Cloud. I have only 2 minimal plugins setup Gapps engine and Batchache manager There are no posts, no other plugins. I have no visitors or followers. My issue is I still have an active connection with Google Coud SQL which is charged at 0.025 per hour. I have 1 connection which always stays on. T...
Importing database to Google Cloud SQL error: "mysql_query Duplicate entry '1' for key 'PRIMARY"
I am trying to import a (Wordpress) database, exported from a local XAMPP installation into a Google cloud SQL database. I followed the steps from the Google documentation, so completed the following steps: Now I got the following error: I installed a wordpress database before the import, so maybe I need to remove the existing database, or leave it...
WordPress website too slow in Google App Engine & Cloud SQL
I just created a WordPress website using Google App Engine for PHP and Cloud SQL service for MySQL back-end. It doesn't have large content. It just starter website with buddypress. But it's too slow to load a webpage on first-time. Since am using some recommended cache plugins it's pretty decent on repeated page hits. I almost tried everything reco...
Can't connect to google cloud sql from server
I've created sql instance on google cloud platform,and I have an existing live wordpress website sitting on a server, I have added the website ip address to the instance connection authorised networks. I even added 0.0.0.0/0 to allow all networks to connect. The problem is I can connect to the instance database from my local machine weather with my...
Using mysqli_connect() for Wordpress connection to Cloud SQL on Google App Engine
I am trying to run Wordpress on Google App Engine standard environment. I have configured a Cloud SQL for MySQL Second Generation instance and can access it using Cloud SQL Proxy with this command: The wp-config.php file: Finally, I connect to the database using this: This setup works perfectly from the local development environment, which is Cloud...
Connect to Cloud SQL in Google App Engine using mysqli_connect
I am trying to configure my Wordpress site in the Google App Engine standard environment. I have configured a Cloud SQL for MySQL Second Generation instance and can access it using Cloud SQL Proxy. The problem I have is connected to the Cloud SQL instance after the app has been deployed to the Google App Engine (GAE) environment. Here are two diffe...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy .