CARVIEW |
Select Language
HTTP/2 200
date: Thu, 09 Oct 2025 00:08:55 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-robots-tag: none
etag: W/"e5dfb0176efb4de3b18451b7ec92d4fe"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com github.githubassets.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com marketplace-screenshots.githubusercontent.com/ copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=T60hS7%2FkC27M7TGOe3ttmedxXNH%2FFcWfTXLD%2BDC9zcF1Ii7f0pyJKYE7JLM52g0w%2FLMqn7fsLh9oxVS98CkGrb%2FY69jMFM7iLLnBuyziC0L5TJIGSYEU7AdcYweXGxoIFVTaAuPSzV0VGhwLp4pleMH5xxHVHEen1Rv4zJAZM6%2FlwmRIxonF8npTVZ0JFquzSjWL5FuaGQHxHA%2BwofpX1kGNTMMQgXlBta1rhIo4B9ghqs15yzCbV%2BgFEo2HvfyLC8F9b9yB6iLBbCjEeJSZKg%3D%3D--poM56%2Fk1Ppom3CA7--8ZVJmKQogYNH0rhD6ah%2FhQ%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1368165480.1759968535; Path=/; Domain=github.com; Expires=Fri, 09 Oct 2026 00:08:55 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Fri, 09 Oct 2026 00:08:55 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: D142:3F3FA7:1B92CD:26D24F:68E6FD17
Simple example to get started · skoerfgen/ACMECert Wiki · GitHub
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 34
Simple example to get started
Stefan Körfgen edited this page Mar 7, 2024
·
5 revisions
<?php
// Simple example to get started
// This can be run by a cronjob for example (no need to time it exactly,
// just run it often enough). It checks if the already existing certificate
// needs to be renewed before making any connection to the CA
// Require ACMECert
require 'ACMECert/ACMECert.php';
use skoerfgen\ACMECert\ACMECert;
// Choose Certificate Authority (CA)
// Let's Encrypt Staging CA
$ac=new ACMECert('https://acme-staging-v02.api.letsencrypt.org/directory');
// Check if the previous certificate needs to be renewed (if there is one already)
if (file_exists(__DIR__.'/fullchain.pem')){
$days=$ac->getRemainingDays('file://'.__DIR__.'/fullchain.pem');
if ($days>30) { // renew 30 days before expiry
echo 'Certificate still good, exiting..';
exit();
}
}
// Check if account_key.pem exists. If not generate new key and
// register it with the CA and save it.
if (!file_exists(__DIR__.'/account_key.pem')){
// Generate RSA Private Key
$key=$ac->generateRSAKey(2048);
// load new key into ACMECert
$ac->loadAccountKey($key);
// Register Account Key with CA
$ac->register(true,'info@example.com');
// Registration succeeded, save key to account_key.pem
file_put_contents(__DIR__.'/account_key.pem',$key);
}else{
// load existing account key into ACMECert
$ac->loadAccountKey('file://'.__DIR__.'/account_key.pem');
}
// Get Certificate using http-01 challenge
$domain_config=array(
'test1.example.com'=>array('challenge'=>'http-01','docroot'=>'/var/www/vhosts/test1.example.com'),
'test2.example.com'=>array('challenge'=>'http-01','docroot'=>'/var/www/vhosts/test2.example.com')
);
$handler=function($opts){
$fn=$opts['config']['docroot'].$opts['key'];
@mkdir(dirname($fn),0777,true);
file_put_contents($fn,$opts['value']);
return function($opts){
unlink($opts['config']['docroot'].$opts['key']);
};
};
// Generate new certificate key
$private_key=$ac->generateRSAKey(2048);
$fullchain=$ac->getCertificateChain($private_key,$domain_config,$handler);
// Success! Save the certificate chain and private key
file_put_contents(__DIR__.'/fullchain.pem',$fullchain);
file_put_contents(__DIR__.'/private_key.pem',$private_key);
// Reload the webserver
You can’t perform that action at this time.