after enabling SSL/HTTPS secure url, try to access the admin page will give:
Invalid Form Key, pls refresh page;
404 Not Found, oops;
In the log file can see the error:
Request validation failed for CsrfValidator.php error
[2023-04-13T09:44:51.329240+00:00] main.DEBUG: Request validation failed for action "Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor" {"exception":"[object] (Magento\\Framework\\App\\Request\\InvalidRequestException(code: 0): Invalid request received at /var/www/magento2/vendor/magento/module-backend/App/Request/BackendValidator.php:176)"} [] [2023-04-13T09:45:14.687675+00:00] main.DEBUG: Request validation failed for action "Magento\Framework\App\Action\Forward\Interceptor" {"exception":"[object] (Magento\\Framework\\App\\Request\\InvalidRequestException(code: 0): Invalid request received at /var/www/magento2/vendor/magento/framework/App/Request/CsrfValidator.php:105)"} [] [2023-04-13T09:46:01.131966+00:00] main.DEBUG: Request validation failed for action "Magento\Framework\App\Action\Forward\Interceptor" {"exception":"[object] (Magento\\Framework\\App\\Request\\InvalidRequestException(code: 0): Invalid request received at /var/www/magento2/vendor/magento/framework/App/Request/CsrfValidator.php:105)"} [] [2023-04-13T09:50:38.416737+00:00] main.DEBUG: Request validation failed for action "Magento\Framework\App\Action\Forward\Interceptor" {"exception":"[object] (Magento\\Framework\\App\\Request\\InvalidRequestException(code: 0): Invalid request received at /var/www/magento2/vendor/magento/framework/App/Request/CsrfValidator.php:105)"} []
So what could be the cause?
A quick search shows a lot of people had this issue even back years ago with magento.
No its not related to the php.ini max var becasue its already 75000, default is 1000
plus it is saying it is invalid form key, why it is related to the max vars?
Some one even posting some temporary work around for this on github:
disable csrf validation entirely in:
Hello @skkj
There are several reasons why you might be encountering these errors after enabling SSL/HTTPS on your Magento website. Here are some possible solutions:
Clear your browser's cache and cookies and try accessing the admin page again. Sometimes, a corrupted cache can cause issues with the form key validation.
Check your Magento configuration to make sure that the base URL for the secure domain is set correctly. To do this, go to System -> Configuration -> Web -> Secure, and make sure that the "Base URL" field is set to the correct HTTPS URL.
Check your server's SSL certificate to make sure that it's valid and installed correctly. You can use an online SSL checker tool to verify your SSL certificate.
Check your Magento file and folder permissions. Make sure that the necessary files and folders are writable by the web server. This can usually be fixed by running the following command in your Magento root directory:
sudo chmod -R 777 var/ pub/ app/
I hope this helps you resolve your issue!