1. Go to this page and download the library: Download likun-mci/acme library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
likun-mci / acme example snippets
$acme = new Acme();
$acme->getHttpClient()->setProxy('socks5h://127.0.0.1:1080');
$acme->getHttpClient()->addNoProxy('internal.corp');
use Mci\Acme\Acme;
use Mci\Acme\Util\Logger;
$acme = new Acme(null, new Logger(Logger::LEVEL_INFO, STDOUT));
$result = $acme->issue(
['example.com', 'www.example.com'],
'/var/www/html', // 或 'dns_cf',或 'no'(standalone)
['email' => '[email protected]', 'key_type' => 'ec-256']
);
if ($result->isIssued()) {
echo $result->getPath('fullchain'), "\n";
echo $result->getCertificate()->getDaysUntilExpiry(), " 天后到期\n";
} elseif ($result->isSkipped()) {
echo $result->getMessage(), "\n"; // 还没到续期窗口
}
// 只想生成一个带 SAN 的 CSR,不走 openssl.cnf
use Mci\Acme\Crypto\{KeyPair, Csr};
$key = KeyPair::generate('ec-256');
$csr = Csr::createPem($key, ['example.com', '*.example.com']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.