2

I need to establish an SSL connection to my PHP-PDO web application. I have MySQL workbench 5.7 and I don't know how and where to start.

I saw different posts online explaining how to do that using mysqld and shell> like 6.4.4 Configuring MySQL to Use Secure Connections and 5.3.4 SSL Wizard (Certificates) in the manual.

I changed the connection to:

$conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass, array(
    PDO::MYSQL_ATTR_SSL_KEY    =>'/etc/mysql/ssl/client-key.pem',
    PDO::MYSQL_ATTR_SSL_CERT=>'/etc/mysql/ssl/client-cert.pem',
    PDO::MYSQL_ATTR_SSL_CA    =>'/etc/mysql/ssl/ca-cert.pem'
    ));
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->exec("SET CHARACTER SET utf8mb4");

Then I went to MySQL workbench and clicked on Database → Connect To Database → SSL Tab → SSL Wizard. I checked Use default Parameters, and I've got this error:

enter image description here

OpenSSL Win64 is installed at C:\OpenSSL-Win64.

What is the problem and how do I fix it?

jww
  • 97,681
  • 90
  • 411
  • 885
alim1990
  • 4,656
  • 12
  • 67
  • 130
  • `C:\OpenSSL-Win64\bin` needs to be on-path. That makes `C:\OpenSSL-Win64\bin\openssl.exe` available to programs that use the command name (`openssl.exe`) rather than a full pathname (`C:\OpenSSL-Win64\bin\openssl.exe`). Or, you need to tell workbench the location of the OpenSSL binary. – jww Jul 21 '17 at 12:16
  • can you be more specific or at least give me the link of the original look a like post – alim1990 Jul 21 '17 at 12:23
  • what is should be on path. Where to define the path in mysql workbench. I think there is no duplication in my question because I didn't see any helping resource from the the link mentioned above. – alim1990 Jul 21 '17 at 12:30
  • Try ['openssl' is not recognized as internal or external command](https://stackoverflow.com/q/20838516/608639). There are questions and answers all over the web about adding directories to `%PATH%` on Windows. You don't need a Stack Overflow post for it. – jww Jul 21 '17 at 12:31
  • I added a path to system variables and still the same error. Re-open the post please – alim1990 Jul 21 '17 at 12:36
  • This is a less than useful statement: *"I added a path to system variables and still the same error..."* - You did not say what value you added, you did not say how you added it, and you did not state if you rebooted. To be pedantic, `%PATH%` is already a system variable so you should not have needed to add it. Please update your question to include the `%PATH%` value (print it from the command line and paste it into the question), and state what you did to effect the changes in system components that may depend on it. – jww Jul 21 '17 at 13:15

1 Answers1

3

For Windows

First make sure openssl is download, here are the download links.

Then you need to add it to your system environment variables. In your start menu search bar, type "Environment Variables," and click "Edit the system Environment Variables."

Then hit the "Environment Variables" button.

Then in either your User or System variables, find the "Path" variable and hit the Edit button.

If you used the openssl x64 installer, and used the default path, it will be "C:\Program Files\OpenSSL-Win64\bin", if you didn't, find the path that contains openssl.exe. Copy the path, without openssl.exe.

Then in your "Edit environment variable" window, hit the New button, and paste that path into it, and save your changes.

Now all you have to do, is to make sure you run MySql Workbench as an Administrator. I assume that is what you forgot to do.

Addio
  • 89
  • 1
  • 6