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

Enable connection to MySQL with SSL/TLS #10784

Closed
Bettelstab opened this issue Oct 1, 2018 · 13 comments
Closed

Enable connection to MySQL with SSL/TLS #10784

Bettelstab opened this issue Oct 1, 2018 · 13 comments
Labels
Database Label: Which BO under menu is concerned Improvement Type: Improvement No change required Resolution: issue closed because expected as is

Comments

@Bettelstab
Copy link

I recently moved my database to an external server and I wanted to use TLS encryption for the database connection. If I remember correctly, I got an SSL connection error in prestashop because there were no SSL options specified. In my case, the only option I needed was MYSQL_ATTR_SSL_CA. At the end, I added it manually in /classes/db/DbPDO.php, line 81:

return new PDO($dsn, $user, $password, array(
            PDO::ATTR_TIMEOUT => $timeout,
            PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
            PDO::MYSQL_ATTR_SSL_CA => '/var/www/html/httpdoc/ca.pem'
        ));

I also had to add it manually in /vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php. There is an $options parameter, but I couldn't get it to work.

I suggest to make the following options configurable:
PDO::MYSQL_ATTR_SSL_KEY, PDO::MYSQL_ATTR_SSL_CERT and MYSQL_ATTR_SSL_CA.

@khouloudbelguith
Copy link
Contributor

Hi @Bettelstab,

Thanks for your report.
@eternoendless, @PrestaShop/prestashop-core-developers what do you think of this issue?

Best regards, Khouloud

@khouloudbelguith khouloudbelguith added Needs Specs Status: issue needs to be specified Database Label: Which BO under menu is concerned labels Oct 1, 2018
@PierreRambaud
Copy link
Contributor

@Bettelstab For the moment you can try to change doctrine configuration in your config.yml file and add these options (do not remove the current configuration).

# Doctrine Configuration
doctrine:
  dbal:
    options:
      MYSQL_ATTR_SSL_CA : %ca_cert%
      MYSQL_ATTR_SSL_KEY : %private_key%
      MYSQL_ATTR_SSL_CERT : %public_cert%

@Bettelstab
Copy link
Author

@PierreRambaud
Thanks! I tried that, but it didn't seem to work. I didn't put too much effort there, though, since I had to do it in a hacky way anyway, so I didn't debug it properly. Even if it works, there are still cases where doctrine is not used and it throws an error then without the change I described above.

@maxtorete
Copy link

maxtorete commented Oct 31, 2018

I was struggling for two days to connect prestashop to my ssl secured remote database. I added PDO::MYSQL_ATTR_SSL_KEY, PDO::MYSQL_ATTR_SSL_CERT and MYSQL_ATTR_SSL_CA as suggested in opening post and it works now. Thanks @Bettelstab !

So it could be great if this can be configured in config files without hacking prestashop core.

Edit: Solution from @PierreRambaud doesn't work here either. I tried to add the config to default connection options too, without success. I tried with const names and values (1009, 1008, 1007) without luck.

@evmimagina
Copy link

Hi,

Any findings? @maxtorete , you when you said it Works, you mean the website but not the /admin site, true? any findings?

Regards,

@maxtorete
Copy link

Hi,

Any findings? @maxtorete , you when you said it Works, you mean the website but not the /admin site, true? any findings?

Regards,

I finished that project long time ago, and finally as we didn't want to hack with PrestaShop core we moved to local database.

So I'm sorry but I can't remember if /admin was working or not, but I far as I can remember, I think both were working fine with @Bettelstab hack. I think I didn't make any changes to /vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php, only /classes/db/DbPDO.php was hacked.

Regards,
Juan

@evmimagina
Copy link

I see, thanks @maxtorete for your reply.
I've finally managed to make it work (there's a bug on prestashop's code).

@PierreRambaud
Copy link
Contributor

@evmimagina Could you tell us more about the PrestaShop bug? :)

@florine2623
Copy link
Contributor

Hello,
Since we had no news from you for more than 30 days, I'll close this ticket to avoid cluttering up the backlog. Please note that you can always create a new one if further information pops up.

Thank you

@prestashop-issue-bot prestashop-issue-bot bot removed the Needs Specs Status: issue needs to be specified label Feb 19, 2021
@florine2623 florine2623 added the No change required Resolution: issue closed because expected as is label Feb 19, 2021
@florine2623 florine2623 mentioned this issue Dec 13, 2021
2 tasks
@thbl
Copy link

thbl commented Dec 13, 2021

@PierreRambaud do you have a guide on how to connect to DB with SSL ?

@thbl
Copy link

thbl commented Dec 18, 2021

@florine2623 why is this closed ?

@matks
Copy link
Contributor

matks commented Dec 19, 2021

@thbl it's written:

Since we had no news from you for more than 30 days, I'll close this ticket to avoid cluttering up the backlog. Please note that you can always create a new one if further information pops up.

No news for more than 30 days -> ticket is closed. Here there was no news for 6 months. We cannot keep open tickets where author does not provide informations.

@matks matks changed the title Database access with SSL/TLS Enable connection to MySQL with SSL/TLS Dec 19, 2021
@matks matks added the Improvement Type: Improvement label Dec 19, 2021
@matks
Copy link
Contributor

matks commented Dec 19, 2021

I renamed this issue for a better title, this is a request for improvement.

We have no guide on how to connect to DB with SSL.

If you find that this improvement is critical for you, and it's important to have it built ASAP, then you can invest into having it done. PrestaShop is an open source, community project. You can hire a developer or sysadmin to find how to do this, or if you are a developer yourself, you can try doing it on your own.

The most important thing is to share that fix with everyone by submitting a Pull Request to devdocs or an improvement to the codebase -- that's what the open source spirit is all about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Database Label: Which BO under menu is concerned Improvement Type: Improvement No change required Resolution: issue closed because expected as is
Projects
None yet
Development

No branches or pull requests

8 participants