yakeing / php_letsencrypt
PHP SSL for letsencrypt.com acme v02
Fund package maintenance!
yakeing
github.com/yakeing/Documentation/blob/main/Sponsor/README.md
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 1
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.6
Requires (Dev)
- phpunit/phpunit: 5.7
README
Letsencrypt
PHP SSL for letsencrypt ACME v2.
Let’s Encrypt is a free, automated, and open certificate authority brought to you by the non-profit Internet Security Research Group (ISRG).
Only PHP client is provided here.
Supporting RSA ECC
Travis CI badge
codecov badge
Packagist badge
Github badge
Installation
Use Composer to install the library. Of course, You can go to Packagist to view.
$ composer require yakeing/php_letsencrypt
Initialization parameter
- Sample:
$le = new letsencrypt(); $option = array(); $option['accountKey'] = '-----BEGIN PUBLIC KEY-----\nMIIBIjA....NjQIDAQA\n-----END PUBLIC KEY----';
Get Directory
- Sample:
echo $le->Directory();
New Nonce
- Sample:
echo $le->NewNonce();
New User Registration
- Sample:
//-----BEGIN PUBLIC KEY-----\nMIIBIjA....NjQIDAQA\n-----END PUBLIC KEY---- $accountKey = $option['accountKey']; $userinfo = array('mailto:yakeing@github.com'); $le->NewAccount($accountKey, $userinfo); $option['kid'] = $le->body['kid'];
New Order
- Sample:
//-----BEGIN PUBLIC KEY-----\nMIIBIjA....NjQIDAQA\n-----END PUBLIC KEY---- $accountKey = $option['accountKey']; $domain = 'example.com'; $kid = $option['kid']; //12345 $type = 'dns'; $le->NewOrder($accountKey, $domain, $kid, $type); $option['authorizations'] = $le->body['authorizations'][0]; $option['finalize'] = $le->body['finalize'];
Get challenges
- Sample:
$jsonAuthz = file_get_contents($option['authorizations']); //array(.....) $authz = json_decode($jsonAuthz, true); foreach ($authz['challenges'] as $value) { if ('http-01' == $value['type']) { //$option['status'] = $value['status']; // valid $option['url'] = $value['url']; $option['token'] = $value['token']; } }
Get Dns Txt
- Sample:
//-----BEGIN PUBLIC KEY-----\nMIIBIjA....NjQIDAQA\n-----END PUBLIC KEY---- $accountKey = $option['accountKey']; $token = $option['token']; //gDhhgh5Sdgf......fGDB0ceWadfg $ret = $le->GetDnsTxt($accountKey, $token); // FrZWluZ0BnaXR......odWIuY29tMFkwE
Challenge
- Sample:
//-----BEGIN PUBLIC KEY-----\nMIIBIjA....NjQIDAQA\n-----END PUBLIC KEY---- $accountKey = $option['accountKey']; $kid = $option['kid']; //12345 $url = $option['url']; //https://~.api.letsencrypt.org/acme/authz-v3/***** $token = $option['token']; //gDhhgh5Sdgf......fGDB0ceWadfg $le->Challenge($accountKey, $kid, $url, $token); //$le->body['status'] == 'valid'
Application for certificate issuance
- Sample:
//-----BEGIN PUBLIC KEY-----\nMIIBIjA....NjQIDAQA\n-----END PUBLIC KEY---- $accountKey = $option['accountKey']; $kid = $option['kid']; //12345 $finalizeUrl = $option['finalize']; //https://~.api.letsencrypt.org/acme/finalize/***/***'; $csr = '-----BEGIN CERTIFICATE-----\nMIIEjjCCA3agAw....NjDNFu0Qg==-----END CERTIFICATE-----'; $outCert = true; $le->GetCert($accountKey, $kid, $finalizeUrl, $csr, $outCert); $Cert = $le->body; //certificate
Certificate revocation
- Sample:
$cerKey = '-----BEGIN PUBLIC KEY-----\nMIIBIjA....NjQIDAQA\n-----END PUBLIC KEY----'; $Cert = '-----BEGIN CERTIFICATE-----\nMIIEA2agAw....HgdYhhE9gj\n==-----END CERTIFICATE-----'; $reason = 0; $le->RevokeCert($cerKey, $cer, $reason);
Domain name deauthorization
- Sample:
//-----BEGIN PUBLIC KEY-----\nMIIBIjA....NjQIDAQA\n-----END PUBLIC KEY---- $accountKey = $option['accountKey']; $kid = 'k6789'; $authKid = 'd12345'; $le->AuthzDeactivate($accountKey, $kid, $authKid);
Change account communication key
- Sample:
//-----BEGIN PUBLIC KEY-----\nMIIBIjA....NjQIDAQA\n-----END PUBLIC KEY---- $accountKey = $option['accountKey']; $kid = $option['kid']; //12345 $newAccountKey = '-----BEGIN PUBLIC KEY-----\nOIYGRjp8....ATy3ggQiyA\n-----END PUBLIC KEY----';; $le->KeyChange($accountKey, $kid, $newAccountKey);
Account deactivation
- Sample:
//-----BEGIN PUBLIC KEY-----\nMIIBIjA....NjQIDAQA\n-----END PUBLIC KEY---- $accountKey = $option['accountKey']; $kid = $option['kid']; //12345 $le->DeactivatedAccount($accountKey, $kid);
Sponsor
If you've got value from any of the content which I have created, then I would very much appreciate your support by payment donate.
Author
weibo: yakeing
twitter: yakeing