1

I'm having difficulties connecting Google Apps Script to my MariaDB instance.

This is the GAS I am using for this example: https://gist.github.com/HappymanOkajima/8740727662e9ba0e0ffd52006484c47f

The MariaDB instance is from the original dockerhub image: mariadb:10.4

I have successfully configured MariaDB to run with SSL (verified with Metabase, and shows 'havessl'='YES')

For context, the following commands were used to generate ssl keys:

Generate key for CA-cert openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 > ./ca-key.pem

Generate CA-cert openssl req -new -x509 -nodes -days 36500 -key ./ca-key.pem -out ./ca-cert.pem -subj "/C=US/ST=NY/L=NTC/O=company/CN=company"

Create SQL server key openssl req -newkey rsa:4096 -nodes -keyout ./server-key.pem -out ./server-req.pem -subj "/C=US/ST=NY/L=NTC/O=company/CN=sql.server.com"

Create SQL server cert openssl x509 -req -in ./kn-req.pem -days 36500 -CA ./ca-cert.pem -CAkey ./ca-key.pem -CAcreateserial -out ./server-cert.pem

Convert server key to RSA (mariadb only reads this) openssl rsa -in ./server-key.pem -out ./server-key-rsa.pem

SQL server is configured with ca-cert.pem, server-cert.pem and server-key-rsa.pem

Create Client Key (for Supermetrics) openssl req -newkey rsa:4096 -nodes -keyout ./client-key.pem -out ./client-req.pem -subj "/C=US/ST=NY/L=NTC/O=company/CN=supermetrics"

Create client cert openssl x509 -req -in ./client-req.pem -days 36500 -CA ./ca-cert.pem -CAkey ./ca-key.pem -CAcreateserial -out ./client-cert.pem

Create RSA version, for Supermetrics openssl rsa -in ./client-key.pem -out ./client-key-rsa.pem

I then used cat to print these files: ca-cert.pem, client-cert.pem, client-key.pem

And copy-pasted the strings into the Google Apps Script, appending \n\ to the end of each line.

This is the error that shows: Exception: Failed to establish a database connection. Check connection string, username and password.

I have also verified that if I removed ?useSSL=true, the connection is completed successfully

What am I missing here? I have scoured every google dev forum posting and stackoverflow questions on this, and they all seem to say that this is the correct solution. Is anyone able to replicate this to verify?

alderson59
  • 11
  • 2
  • Perhaps you could look for similar questions regarding this functionality. Because it might be either on the databse side or on the GAS side.I'd point you to this one: https://stackoverflow.com/questions/44528221/how-to-connect-to-database-with-ssl-in-google-apps-script – A. Perez Cera Mar 16 '21 at 19:52
  • Not helpful. I have searched just about every thread I can find. You are referencing the one that came up the most frequently by SEO. If you look carefully, the example I posted already includes useSSL=true. I am capable of using the search function and google. This question is posted because there isn't an answer out there. Try replicating this and see how you do? – alderson59 Mar 18 '21 at 03:53

0 Answers0