Fix MySQLi SSL flags handling to explicitly set MYSQLI_CLIENT_SSL if … #169
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…use_ssl is set.
Signed-off-by: Ere Maijala ere.maijala@helsinki.fi
Description
This fixes an issue where setting use_ssl to true alone doesn't actually make the connection secure. It is only made secure if any of the client_key, client_cert, ca_cert, ca_path or cipher is also set to a non-empty value.
To reproduce the problem prior to this fix do something like this:
Expected: a non-empty value for Ssl_cipher
Actual: Ssl_cipher is empty
Tested with: PHP 7.2.20
The patch moves mysqli class creation in the Connection class to a helper method to make it easier to test the class and adds a couple of tests that verify the connection parameters using mock objects. The failed connection test is moved last since it sets connect_error property in mysqli, and I couldn't find a simple way to mock or override it later on (trying to mock the __get method causes a warning with PHPUnit).