Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added handling of ssl_mode connection parameter to MySQL session #1104

Closed
wants to merge 2 commits into from

Conversation

willw-git
Copy link

This PR allows SOCI users to pass the ssl-mode parameter described here when connecting to a MySQL database. The setting is passed as ssl_mode, with its value set to one of the name constants given in the above documentation: DISABLED, PREFERRED, REQUIRED, VERIFY_CA and VERIFY_IDENTITY. Used like this:

auto connection_str = "host=localhost db=mydb user=fred pass='12345' ssl_mode=DISABLED";
session sql(mysql, connection_str);

This patch implies that the documentation at https://soci.sourceforge.net/doc/master/backends/mysql/ needs to be fixed to include this parameter and its possible values.

Motivation: I found that a 32-bit client could not connect to a server, even though the server permitted unencrypted connections. The error returned was 2026. I believe this is because the default value of this parameter is PREFERRED, which implies that TLS protocol negotiations are initiated. Because the 32-bit client is no longer maintained, these fail - and no connection is made. The solution is to turn off SSL entirely (if the security situation permits it).

Of course, the parameter is also generally useful.

Copy link
Member

@vadz vadz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'd be glad to add this, but the documentation indeed needs to be updated, could you please add the new option description to docs/backend/mysql.md?

src/backends/mysql/session.cpp Outdated Show resolved Hide resolved
@vadz
Copy link
Member

vadz commented Dec 7, 2023

Oh, and you need to look into whether we can use mysql_options() instead of the deprecated function resulting in CI errors. If we can't, the warning would need to be disabled.

@vadz vadz added the MySQL label Dec 7, 2023
vadz pushed a commit that referenced this pull request Dec 11, 2023
This allows to set MYSQL_OPT_SSL_MODE.

See #1104.
@vadz
Copy link
Member

vadz commented Dec 11, 2023

Thanks for the update, (squash) merged now!

@vadz vadz closed this Dec 11, 2023
@willw-git willw-git deleted the feature/mysql_ssl_mode branch December 11, 2023 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants