0

I wanted to work on a PHP project and as usual I start MAMP to boot up the test server. But instead of my page I got an error message.

First, I started to investigate on the MAMP software, I change the ports, I tried changing the location of the root folder, it didn't change anything. Still that error:

"The connection of this website is not secured - ERR_SSL_PROTOCOL_ERROR".

I switched of browser first Edge and then Safari, nothing changed. I looked up on Google the error and as it would seem, it comes from an invalid certificate. So, I tried forging one with openssl, I could't add the .pem file to the keychain tool, and I tried changing the configuration files http.conf and httpd-vhosts.conf to use the new certificate. It didn't work either. Finally, hopeless, I tried uninstalling MAMP and reinstall it and even tried XAMPP, still no more results.

I'm desperate if anyone had a solution, I would be infinitely grateful!

Edit: Here my httpd.conf file

<https://pastebin.com/SHJ8CdrA>

Edit 2: Here's the new httpd.conf file

<https://pastebin.com/fdZe4RhU>

Edit 3: Here is my httpd-ssl.conf

<https://pastebin.com/RMPJbp6q>
JM Gelilio
  • 3,482
  • 1
  • 11
  • 23
Lowick
  • 11
  • 3
  • Many things could cause this error. We can't help you without more information. Is the server certificate self-signed? If so, you'll need to import it into the browser. What's the certificate's expiration date? What host are you entering into the browser's address bar? Is your system time set correctly? Did you manually configure TLS on the Apache web server, or did MAMP configure TLS out-of-the-box? What does your Apache web sever configuration look like? – Rafael Jun 19 '22 at 18:51
  • Ok, so the certificate I forged was self-signed, but I couldn't start the Apache server after using it in the configuration files. It was set to expire in 1024 days. I entered **localhost:8888** in the browser's address bar. The time on my system is set correctly. I tried to configure TLS with the help of a tutorial on Youtube which didn't work for me. Finally, I will provide a link to a pastebin of the http.conf file – Lowick Jun 19 '22 at 19:17
  • You need to uncomment the `httpd-ssl.conf` include in your Apache configuration. After you uncomment the httpd-ssl.conf include, go ahead and open httpd-ssl.conf. Next, find the `SSLCertificateFile` and `SSLCertificateKeyFile` lines and ensure that the file paths correctly reference your self-signed certificate and key on your file system. – Rafael Jun 19 '22 at 19:45
  • Robert's answer in [Configuring MAMP for SSL](https://stackoverflow.com/questions/6318467/configuring-mamp-for-ssl) is also helpful. – Rafael Jun 19 '22 at 19:46
  • Does this answer your question? [Configuring MAMP for SSL](https://stackoverflow.com/questions/6318467/configuring-mamp-for-ssl) – Rafael Jun 19 '22 at 19:48
  • Now it doesn't want to launch at all. It says "Apache couldn't be started. Please check your MAMP installation and configuration." – Lowick Jun 19 '22 at 19:54
  • @Rafael I followed the instructions, I double checked though MAMP still gives me an error – Lowick Jun 19 '22 at 20:16
  • Please share your latest Apache configuration and `httpd-ssl.conf`. – Rafael Jun 19 '22 at 23:44
  • @Rafael Just edited my post with the files – Lowick Jun 20 '22 at 16:49
  • In httpd-ssl.conf, the ServerName directive is set to `www.example.com:443`. However, your self-signed certificate is probably for `localhost`. Set ServerName to `localhost:443`. Confirm that your certificate and key are located at `/Applications/MAMP/conf/apache/server.crt` and `/Applications/MAMP/conf/apache/server.key`, respectively. Also, confirm that they are [PEM-encoded](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail). Restart Apache and retry. – Rafael Jun 20 '22 at 17:27
  • @Rafael I've changed the ServerName to localhost:443, the certificate and its key are in the right location. I followed the guidelines of the answer in your link to generate the certificate [Configuring MAMP for SSL](https://stackoverflow.com/questions/6318467/configuring-mamp-for-ssl) – Lowick Jun 20 '22 at 19:46
  • Did you import the self-signed certificate into your browser? – Rafael Jun 20 '22 at 21:27
  • I added the certificate to my Keychain but the issue now is that the server doesn't start at all... – Lowick Jun 20 '22 at 22:52
  • Check the following two log files: 1) `/Applications/MAMP/Library/logs/error_log` 2) `/Applications/MAMP/logs/apache_error.log`. – Rafael Jun 21 '22 at 01:09
  • @Rafael 1) There's no log file in /Applications/MAMP/Library/logs/ 2) The other one doesn't have any entry since 4 days even if I restart the server the file is still the same – Lowick Jun 24 '22 at 16:24

1 Answers1

1

So, after a long time searching and testing, I got the same issue on my Windows PC with XAMPP. I don't remember exactly the fix but it was related to the configuration files http.conf and httpd-ssl.conf I just copy paste the files from my Windows PC to my Mac and it worked.

In the meantime, I used the PHP command php -S localhost:8000 to run my application and I installed and ran a standalone instance of MySQL.

TL;DR : Always check your config files and check on another machine.

Lowick
  • 11
  • 3