WhatsApp / WhatsApp-Business-API-Setup-Scripts

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

Change wa-db-engine to lowercase in db.env file (kubernetes config) #24

Closed thiagomendes closed 4 years ago

thiagomendes commented 4 years ago

During my configuration of the whatsapp business kubernetes environment, I noticed a problem in the loading of the environment variables responsible for the loading of the attributes for ssl connection between the web application and mysql.

This problem occurs due to the value set in the wa-db-engine attribute of the db.env file.

The value set in this file is in uppercase (MYSQL), but internally in the web application code, inside the DBUtil.php file, it performs some comparisons with a constant called DB_MYSQL, which has its lowercase value (mysql) inside the Constants file .php.

When creating the connection, before loading the environment variables responsible for the SSL settings, it compares the value of this constant (DB_MYSQL) with the value set in the environment variable (WA_DB_ENGINE) of the webapp.yml file. The value of this environment variable is filled in using the value set in the db.env file, using a reference to the wa-db-engine attribute.

If this comparison fails, it does not load the environment variables for configuring the ssl properties that are used to connect to mysql.

When these environment variables are not loaded properly and you are pointing to an SSL connection url, you receive an error when creating the connection.

This is the error message: SSL connection is required. Please specify SSL options and retry.

To solve this problem, I believe that it is necessary to change the value of the property wa-db-engine to minuscule in the file db.env or adjust the logic used in the file DBUtils to load the environment variables related to the SSL settings.

mengyiyuan commented 4 years ago

Hi Thiago,

Thanks a lot for the prompt solution. I do believe that we should make changes to the code in DBUtil.php, rather than change the env var value we pass in.

Please give me some time to discuss this with the team and get back to you.

thiagomendes commented 4 years ago

Hi Mengyiyuan,

I really think this is the best way to solve the problem (change DBUtil file), this way it reduces the risk of impacts on other flows that may use this environment variable.

On my side, until we have a fix in the PHP code, I will change the environment variable temporarily.

Thanks for your return.

mengyiyuan commented 4 years ago

@thiagocmoraes that makes sense. :) Thanks again for reporting the issue. I will close this issue for now as we are tracking this request internally.