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
[3.x]: Database backup after composer update not working with SSL #11753
Comments
Was this working before an update and broke after or has it never worked for you? If the prior, do you recall the version you were on before? |
It was working before we had to add the SSL variable in the db.php. We recently moved our database to an environment where this is required |
Any updates on this? I also migrated to an env that requires SSL and DB backups no longer work using mysqldump.
|
this should fix the problem: |
@carolineboeykens Does that help? |
@brandonkelly , We got this error message:
Is it because the code is not checking the attributes from the db.php in the command? <?php
$params = [
'dsn' => getenv('DB_DSN'),
'user' => getenv('DB_USER'),
'password' => getenv('DB_PASSWORD'),
'schema' => getenv('DB_SCHEMA'),
'tablePrefix' => getenv('DB_TABLE_PREFIX'),
];
if(getenv('ENVIRONMENT') != 'dev') {
$params['attributes']= [
PDO::MYSQL_ATTR_SSL_CA => '/etc/ssl/certs/ca-bundle.crt'
];
}
return $params; |
@carolineboeykens Can you take that generated command and add the --ssl-ca flag to it and try to execute it (obviously swapping the *** back with their original values). Something like:
There are other SSL command line flags, but I'm guessing that's the one you want, based on your db.php file. Also worth mentioning is that by using https://craftcms.com/docs/4.x/config/general.html#backupcommand, you can completely override Craft's default backup command with whatever you need. |
Hi @angrybrad , When we leave this part out, we get an error from the mysql socket: Is this related to this issue or is this a problem with the server? The website and the connection with the database are working fine, justs not with this command. |
This is fixed now for the next Craft 3 and 4 releases, via #12596. Thanks @okolvik-avento! |
Craft 3.7.64 and 4.3.7 have been released with that fix. |
What happened?
Description
Our server requires an SSL connection on our database. We added the following code to the config/db.php
if(getenv('ENVIRONMENT') != 'dev') { $params['attributes']= [ PDO::MYSQL_ATTR_SSL_CA => '/etc/ssl/certs/ca-bundle.crt' ]; }
Now the database backup on our production server won't work:
mysqldump: Got error: 3159: “Connections using insecure transport are prohibited while --require_secure_transport=ON.” when trying to connect
Steps to reproduce
Expected behavior
Does the database backup not use the parameters from db.php?
Craft CMS version
3.7.40
PHP version
7.4
Operating system and version
CentOS Linux
Database type and version
MySQL 8.0.26
Image driver and version
Imagick 3.7.0 (ImageMagick 6.9.12-55)
Installed plugins and versions
The text was updated successfully, but these errors were encountered: