BLUF: Cockpit works well without SSL. Installing SSL gives me PHP errors. Why?
My System:
- MacOS Mojave
- Apache 2.4
- PHP 7.3
The Background:
I installed Cockpit and built a front end in two separate folders with virtual hosts.
- Cockpit CMS
- Located in
project-folder/cms/
- Virtual host:
cms.project-folder.test
- Located in
- Front end files (PHP, CSS, JS)
- Located in
project-folder/site/
- Virtual host:
project-folder.test
- Located in
I created some content in Cockpit, and displayed the content in my front end via PHP. This works.
Then I wanted to use SSL…
The Problem:
-
I installed SSL certs in
project-folder/certs
andproject-folder/certs/cms
, and configured them in my virtual hosts config file. -
I added the certs to my Keychain, and SSL works. I know it’s configured correctly, as I’m successfully using the same method for 4 other sites with no problem.
-
I setup SSL in
.htaccess
files in both thecms
andsite
folders.-
/project-folder/site/.htaccess
:RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
-
/project-folder/cms/.htaccess
:I followed the existing rewrite code in Cockpit’s
.htaccess
:# URL rewrites <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On # RewriteBase / # Protect some contents RewriteRule ^.*/?\.git+ - [F,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php [L] </IfModule>
with this code:
# SSL <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] </IfModule>
-
Now when I open cms.project-folder.test
it correctly redirects to https://cms.project-folder.test
and I can login to Cockpit without issues.
When I want to view the front end, when I open project-folder.test
it correctly redirects to https://project-folder.test
, but instead of loading content from Cockpit, I get several error messages like this:
The Error Message:
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
- Does Cockpit work with SSL?
- Does it seem like my SSL is configured wrong in
.htaccess
? - Does it seem like the problem is in my PHP (even though it works fine without SSL)?