Posts by axl

    A good solution for fixing Let's Encrypt, but...

    everything seems to work with the letsencrypt patch, but I discovered a problem when installing a purchased certificate ...

    To install a paid certificate line 134 needs to be reactivated in OpenSSL.pm (afterwards deactivate again).

    ... it had issues with paid certificates.


    I continued the work on Joern's approach. As per his instructions, start with:

    Code
    1. cd /usr/share/ca-certificates/mozilla/
    2. wget https://letsencrypt.org/certs/lets-encrypt-r3.pem
    3. mv lets-encrypt-r3.pem lets-encrypt-r3.crt
    4. dpkg-reconfigure ca-certificates # -->> add new letsencrypt Cert

    The next step is to edit /var/www/imscp/engine/PerlLib/iMSCP/OpenSSL.pm with editor of your choice. As Joern instructed, start by commenting out the line at 135. However, to allow paid certificates with CA bundle continue to work, if the initial verify command fails, then we need to try to run it with the CAfile parameter. This is done by adding the code below after line 140 debug( $stdout ) if $stdout;:

    Full code from line 132 (old) to 157 (new) with a few comments for clarity:


    Disclaimer: use at your own risk.

    Problem B - exists since 5.0.3 and still in 5.0.5:

    When switching a site back to the default phpversion or when creating a new customer with default phpversion, the same problem from above now hits all pages wich are using the default php version. The command perl /var/www/imscp/engine/imscp-rqst-mngr -v is not able to fix this problem, but with a fast reconfiguration perl /var/www/imscp/engine/setup/imscp-reconfigure -danv this problem gets hotfixed aswell in the meantime. But it seems like there is still another problem hidden in the phpswitcher.

    Spent some time trying to work on this, and found a probable cause and a fix for it. I could not cause the default PHP version pool configurations to be deleted on a domain creation or deletion. However, there is a bug related to the php_compiler.pl, which causes all the pool configurations to be wiped for the default PHP version.


    The issue


    When using the compiler, all the PHP versions processed get changed to either toadd or tochange state. Then, run-method on backend/PhpSwitcher.pm will run _deconfigureFpm for all the affected PHP versions.


    On the very last line of _deconfigureFpm, there is a function call:

    unlink grep !/www\.conf$/, glob "$phpVersion->{'version_fpm_pool_directory_path'}/*.conf"; This will delete all the pool configs besides the www.conf. This is fine for PHP versions other than default. run will then call _scheduleDomainsChange, which will change the status of domains, subdomains, aliasses and subdomain aliasses to tochange if they have a non-default PHP-version. When the backend tasks are run, the pool configurations get recreated for these.


    So, in summary, all PHP versions will have their pool configurations deleted, but only the ones with non-default PHP-version gets recreated. Because the default PHP service is not reloaded, the issue will not be visible until someone adds a domain or changes back to default PHP version.


    The solution


    The fix seems to be quite simple. You have to edit backend/PhpSwitcher.pm and change the end (should be line 1787) of _deconfigureFpm from

    Code
    1. unlink grep !/www\.conf$/, glob "$phpVersion->{'version_fpm_pool_directory_path'}/*.conf";

    to

    Code
    1. # Prevent default PHP file configurations from being destroyed
    2. return if $phpVersion->{'version_is_default'};
    3. unlink grep !/www\.conf$/, glob "$phpVersion->{'version_fpm_pool_directory_path'}/*.conf";

    Disclaimer: use at your own risk.


    Additional help


    If you managed to end up in a state where all the pool configurations for default PHP versions are gone, there is a faster alternative to perl /var/www/imscp/engine/setup/imscp-reconfigure -danv. Basically, you need to change the state of domains, subdomains, aliasses and subdomain aliasses with default PHP version to tochange, and run the request manager with /var/www/imscp/engine/imscp-rqst-mngr or from admin via Debugger -> Run Tasks. To change all the states, you can run these SQL queries:

    Disclaimer: use at your own risk.