-
Notifications
You must be signed in to change notification settings - Fork 330
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
"Could not load the client key from..." on 2.2.0 #1242
Comments
It seems like the connection string has the literal text |
I manually replaced the file path with that variable-looking-bit because I didn't want to share the actual filepath (since it includes internal info in the path, but it starts with "/var/lib/")... the real value is definitely a valid path. Also note that it works perfectly without any changes at all on 2.1.13, and only fails on 2.2.0, if it was a simple issue like that, both would have failed. Also to note, if I put in an invalid server name, the error I get changes to Ideas on what to look for? Any extra debugging I can turn on? |
Sorry, I got confused by how you were obfuscating the path in your bug report.
You can enable verbose logging with: MySqlConnector.Logging.MySqlConnectorLogManager.Provider = new MySqlConnector.Logging.ConsoleLoggerProvider(MySqlConnector.Logging.MySqlConnectorLogLevel.Trace); |
There should also be an inner exception with more details on what caused the problem. Can you paste in the full exception message and call stack (with line numbers), obfuscating any sensitive details as necessary? |
No worries, random complaints with little context don't always create the smoothest environment for initial troubleshooting =) Here's the more complete exception:
And the innerException:
For reference: Translated to Powershell, the log trace config is done via
Here's the trace :
Not a ton of extra value from the trace, it really looks like it's choking on parsing the keyfile. |
OK, I got this working... so I'm happy to close this now. Thank you for your help! The fix: Use the net6.0 version of the library. The background: Further digging for curiosity: The next line in the successful test was So it appears the netstandard2.1 library wasn't doing CA validations, the net6.0 one does, and something that changed from 2.1.13 to 2.2.0 actually causes that to matter, which seems like a good thing. Just not obvious. If you want more info from me on this, I'm happy to continue. But from what I sit, the issue is resolved |
Thanks; this is really helpful information. There are platform-specific branches in the code (based on new APIs that .NET 6.0 supports but MySqlConnector/src/MySqlConnector/Core/ServerSession.cs Lines 1584 to 1612 in 41aa751
|
If I'm following correctly (I only looked at the exception there, I didn't go back track the call tree), it looks like the bug would be that the originating exception is getting shadowed. That highlighted exception would have made a ton more sense to have received. I wouldn't have made immediate sense to me, but would have matched to the library loading and jumped straight to the issue. Nice find. |
This was a regression introduced in 0bb5885#diff-5241314214d7d3cbf2c0e9abe9d16662d192838238ea9fa4b0dd9ee73046c8ceL716-R717. |
Fixed in 2.2.1. |
Software versions
MySqlConnector version:
Server type (MySQL, MariaDB, Aurora, etc.) and version: MySQL 8.0.29-21 (per
show variables like ‘%version%’;
).NET version: 6.0.8 (as reported by
[environment]::Version
in Powershell 7.2.6)(Optional) ORM NuGet packages and versions:
Describe the bug
When I attempt to connect to a MySQL database using a certificate for authentication, I get the below exception. (variables substituted in to avoid exposing info). This works normally in 2.1.13, but not 2.2.0.
Exception
MethodInvocationException: Exception calling "Open" with "0" argument(s): "Could not load the client key from $KEYPATH"
Code sample
Expected behavior
I expected to get a populated connection record.
Additional context
This works as expected on 2.1.13, it only started failing on 2.2.0. My test containers were built within a minute of each other, with the only difference being the MySqlConnector version... both had same access to the key. So the issue seems to be how 2.2.0 is parsing the key, not its access to the key or changes in OS libraries.
The text was updated successfully, but these errors were encountered: