WhatsApp / WhatsApp-Business-API-Setup-Scripts

The scripts related to setting up WhatsApp business API
MIT License
410 stars 433 forks source link

Connection to MySQL Database with required SSL #31

Closed patrick-zimmermann closed 4 years ago

patrick-zimmermann commented 4 years ago

I try to setup the WhatsApp Business API with an external MySQL database (Azure Database for MySQL). That database requires SSL (see here).

I already followed the instructions from the official documentation (see here). However, it looks like that the whatsapp-web component ignores the defined environment variables. I uploaded the certificates to the defined path (/usr/local/waent/data/certs). The connection via terminal to the database works. Also, if I disable the SSL setting on the MySQL database the connection works as well.

The error message I see in the logs: SSL connection is required. Please specify SSL options and retry

Could you please provide an dedicated example for enabled SSL configuration.

whatsapp-web env:

...
env:
  - name: WA_DB_SSL_CA
    value: "/usr/local/waent/data/certs/filename.crt.pem"
volumeMounts:
  - name: whatsapp-media
    mountPath: /usr/local/waent/data
...

The defined path above (/usr/local/waent/data) is mounted as a persistent volume on the kubernetes system.

The error log from the pod.

PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000] [9002] SSL connection is required. Please specify SSL options and retry. in /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:2
Stack trace:
#0 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(2): PDO->__construct('mysql:host=app-...', '...', '...', Array)
#1 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php(2): Doctrine\DBAL\Driver\PDOConnection->__construct('mysql:host=app-...', '...', '...', Array)
#2 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(2): Doctrine\DBAL\Driver\PDOMySql\Driver->connect(Array, '...', '...', Array)
#3 /var/www/html/src/WhatsApp/Database/DBConnection.php(2): Doctrine\DBAL\Connection->connect()
#4 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(2): WhatsApp\Database\DBConnection->connect()
#5 /var/www/html/vendor/doctrine/dbal/lib in /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php on line 2
SSL Hardened
SSL enabled

We are using the latest version 2.27.12.

mengyiyuan commented 4 years ago

@patrick-zimmermann this may be related to what was reported in #24, for now to solve it, try to use WA_DB_ENGINE=mysql instead of WA_DB_ENGINE=MYSQL when you start the container.

The SSL settings should be picked up this way. We've already made the fix which will be included in the next release.

Let me know if this temporary fix works, thanks!

patrick-zimmermann commented 4 years ago

@mengyiyuan Thanks for your quick response. Changing the parameter to lowercase did indeed solved the issue.

As far as I can tell, you only need to change it in the webapp. The master and core can be left uppercase, right?

mengyiyuan commented 4 years ago

@mengyiyuan Thanks for your quick response. Changing the parameter to lowercase did indeed solved the issue.

As far as I can tell, you only need to change it in the webapp. The master and core can be left uppercase, right?

That's right. Only in webapp.

patrick-zimmermann commented 4 years ago

Perfect, thanks a lot!

Rajamohanreddyai commented 3 years ago

Hello ,

I was created the whole setup at that time I got the same error, but at the next second I was fixed the same. Mainly because of 2 reasons you may get the URL not found errors.

Containers are not up (db, coreapp, webapp). You might be calling the wrong URL. Please check the below link if do you want any clarity. https://youtu.be/hYO32rQQ9Pc