My database requires a SSL secured connection, but when I connect with this DB connection string:
I get the follwing error:
Traceback (most recent call last): File "/app/utopia_hub.py", line 9, in backend = get_backend("mysql://[user]:[pass]@[server]/[database]?ssl=yes&sslca=server-ca.pem&sslkey=client-key.pem&sslcert=client-cert.pem") File "/usr/local/lib/python3.8/site-packages/yoyo/connections.py", line 95, in get_backend return backend_class(parsed, migration_table) File "/usr/local/lib/python3.8/site-packages/yoyo/backends.py", line 164, in init self._connection = self.connect(dburi) File "/usr/local/lib/python3.8/site-packages/yoyo/backends.py", line 639, in connect return self.driver.connect(**kwargs) File "/usr/local/lib/python3.8/site-packages/pymysql/init.py", line 94, in Connect return Connection(*args, **kwargs) TypeError: init() got an unexpected keyword argument 'sslca'
After looking at the library code I believe I have found the issue. It seems to reside in the backends.py file, MySQLBackend class, connet method. The method extracts the ssl keyword and overwrites it with an empty dict, and then fills it with the sslca, sslcapath, sslcert, sslkey and sslcipher information.
Prior to that, it populates the kwargs with the dburi args, that include the before mentioned arguments, that results in the above mentioned error. Additionally, the logic does not allow for the check_hostname argument, that I require to be able to set to false.
I think a better way to do this would be to alter or remove the "if "ssl" in dburi.args:" logic to allow the user to simply provide a connection string that looks something like this:
mysql://[user]:[pass]@[server]/[database]?ssl={'ca': 'server-ca.pem', 'key': 'client-key.pem', 'cert': 'client-cert.pem', 'check_hostname': False}
mysql-connector-python 8.0.20 PyMySQL 0.10.0 yoyo-migrations 7.2.0
PRETTY_NAME="Debian GNU/Linux 10 (buster)" NAME="Debian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"