...

New SSL Standard Hooks for cPanel & WHM Integrators! | cPanel Blog

New SSL Standard Hooks for cPanel & WHM Integrators! | cPanel Blog

Hello, all you lovely people out in third-party developerland!

Don’t you hate it when you’re installing an SSL certificate through a script or API calls, but there’s some action that you want to take before or after the installation? Well, thanks to the hardworking folks on the Development Team, cPanel & WHM Version now includes a Standardized Hook for the SSL Installation event.

What is a Standard Hook?

Standardized Hooks are our way to help developers trigger events when cPanel & WHM performs a specific action. Developers use the Standard Hooks system to execute custom code (hook action code) to customize how cPanel & WHM reacts in specific scenarios (hookable events). For example, you could use this system to make certain that a script runs each time a cPanel account is created or terminated.

Take advantage of the new SSL Hooks

With the new hooks, you can automatically run code before and after the installation process. For example, if you want to touch a file  /var/cpanel/hooks_test_log_post whenever an SSL is installed you would create the /usr/local/cpanel/3rdparty/bin/techhookpost.pm script hook with the following code  (provided in Perl):

package Testhookpost; use strict;
use warnings; use JSON; # Embed hook attributes alongside the action code.
sub describe { my $my_add = { 'category' => 'Whostmgr', 'event' => 'SSL::installssl', 'stage' => 'post', 'hook' => 'Testhookpost::do_the_thing', 'exectype' => 'module', }; return [ $my_add ];
} sub do_the_thing { my ( $context, $data ) = @_; my $filename = '/var/cpanel/hooks_test_log_post'; open HANDLE, ">>$filename" or die "touch $filename: $!n"; close HANDLE; my $result = 1; my $message = 'OK'; return $result, $message;
} 1;

Then, you would use the manage_hooks utility to register that hook:

bin/manage_hooks add script /usr/local/cpanel/3rdparty/bin/testhookpost.pm

In addition to the SSL certificate installation hook, we’ve also created an AutoSSL certificate installation hook.

Twice the fun, and twice the power!

These new hooks join the family of our other fine Standardized Hooks that you’ve come to know, love, and rely upon.

For more information, read our delicious Standardized Hook SSL documentation.


A note from benny:

Ready to give it a try? This feature is already available to any server with a supported version of cPanel & WHM. You can also join us in our slack or discord channels, post your questions on the cPanel forums or subreddit, or come visit Houston, Texas for the 2018 cPanel Conference, October 1st – 3rd. 

Discover more from WIREDGORILLA

Subscribe now to keep reading and get access to the full archive.

Continue reading