コード例 #1
0
/**
 * @param \PhpAmqpLib\Message\AMQPMessage $msg
*/
function process_message($msg)
{
    //  load content queue
    $content = json_decode($msg->body, TRUE);
    // echo "<pre>"; print_r($content); echo "/<pre>";
    if ($content['action'] === 'create' || $content['action'] === 'renew') {
        $renew = $content['action'] === 'renew';
        $infos = $content['infos'];
        $db = new VHFFS();
        $vh = $db->get_httpd_from_servername($infos['domain']);
        $vl = VHFFS_letsencrypt::get_from_httpd_id($vh->httpd_id);
        if (empty($vl)) {
            $vl = new VHFFS_letsencrypt($vh->httpd_id);
        }
        $error = create_cert($infos, $renew);
        if (isset($error)) {
            $vl->cert_error($error);
        } else {
            $vl->cert_ok();
        }
        $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
    }
}
コード例 #2
0
#! /usr/bin/php
<?php 
//  execute this script in a daily crontab to enable auto-renew of your VHFFS let's encrypt certificates
require_once __DIR__ . '/includes/autoload.inc.php';
require_once __DIR__ . '/vendor/autoload.php';
// query DB, loop domains to renew
$servernames = VHFFS_letsencrypt::get_servernames_to_renew();
foreach ($servernames as $servername) {
    ask_for_cert('renew', $servername);
    //TODO invoke a renew method instead of create
}
//TODO if vhffs_httpd cannot be found, revoke certificate and remove config from nginx