{"id":15917502,"url":"https://github.com/takuya/php-letencrypt-acme-dns","last_synced_at":"2025-03-24T07:32:04.462Z","repository":{"id":66024681,"uuid":"602491133","full_name":"takuya/php-letencrypt-acme-dns","owner":"takuya","description":"DNS-01 ACMEv2 suport Library helps us to obtain Let's Encrypt SSLCertificate ","archived":false,"fork":false,"pushed_at":"2024-10-29T11:15:31.000Z","size":176,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-29T13:13:36.973Z","etag":null,"topics":["acme-client","acme-dns","acme-v2","pure-php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/takuya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-16T10:21:50.000Z","updated_at":"2024-10-29T11:15:34.000Z","dependencies_parsed_at":"2023-03-10T23:29:42.547Z","dependency_job_id":"a94b5c6e-0555-4dc2-bac6-b78d263e2d08","html_url":"https://github.com/takuya/php-letencrypt-acme-dns","commit_stats":{"total_commits":407,"total_committers":1,"mean_commits":407.0,"dds":0.0,"last_synced_commit":"e044fb7c7e9e7ab2ad5e9e0fff56cd8136268152"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fphp-letencrypt-acme-dns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fphp-letencrypt-acme-dns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fphp-letencrypt-acme-dns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fphp-letencrypt-acme-dns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/takuya","download_url":"https://codeload.github.com/takuya/php-letencrypt-acme-dns/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245227519,"owners_count":20580893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acme-client","acme-dns","acme-v2","pure-php"],"created_at":"2024-10-06T18:11:05.783Z","updated_at":"2025-03-24T07:32:04.188Z","avatar_url":"https://github.com/takuya.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## LetsEncrypt for ACME DNS-01 and Cloudflare or your own\n[![phpunit](https://github.com/takuya/php-letencrypt-acme-dns/actions/workflows/actions.yml/badge.svg)](https://github.com/takuya/php-letencrypt-acme-dns/actions/workflows/actions.yml)\n[![composer](https://github.com/takuya/php-letencrypt-acme-dns/actions/workflows/composer.yml/badge.svg)](https://github.com/takuya/php-letencrypt-acme-dns/actions/workflows/composer.yml)\n\nThis Library helps us to obtain Let's Encrypt SSLCertificate with DNS-01 ACMEv2.\n\nThis is **Pure-PHP** , intend to be LE embedded WEB-PHP-App (ex. laravel). \n\n**Independent** from `shell command` like `certbot`.   \n\n### Run ACME. \nrequest issue of certificate by DNS-01.\n\nshell\n```php\nexport LE_CLOUDFLARE_TOKEN='X-811Gxxxxx'\nexport LE_EMAIL='yourname@example.tld'\nphp bin/request-issue.php 'aab.example.tld' 'aaa.example.tld'\n```\n\n### EXAMPLE\nIn you php code.\n\n```php\n\u003c?php\n\n/** ********\n * Prepare\n */ \nuse Takuya\\LEClientDNS01\\Account;\n$cf_api_token = getenv( 'LE_CLOUDFLARE_TOKEN' );\n$your_email   = getenv( 'LE_EMAIL' );\n$domain_names = [\"www.your-domain.tld\",'*.www.your-domain.tld'];\n$account = new Account( $your_email );\n/** ********\n * Order certificate.\n */\n$dns = new CloudflareDNSPlugin( $cf_api_token, base_domain($domain_names[0]) );\n$cli = new LetsEncryptAcmeDNS( $account );\n$cli-\u003esetDomainNames( $domain_names );\n$cli-\u003esetAcmeURL( LetsEncryptACMEServer::PROD );\n$cli-\u003esetDnsPlugin( $dns );\n$cert_and_a_key = $cli-\u003eorderNewCert();\n/** ********\n * Save in your own way.\n */\n$owner_pkey = $account-\u003eprivate_key;\n$cert_pem  = $cert_and_a_key-\u003ecert();\n$cert_pkey = $cert_and_a_key-\u003eprivKey();//domain pkey, not an owner's pkey. \n$full_chain = $cert_and_a_key-\u003efullChain();\n$pkcs12     = $cert_and_a_key-\u003epkcs12('enc pass');\n$cert_info = new SSLCertificateInfo( $cert_and_a_key-\u003ecert(); );\n```\n### More cases.\n\n\n#### WildCard name. \n```php\n$cli-\u003esetDomainNames( ['*.your-domain.tld'] );\n```\n#### Single name\n```php\n$cli-\u003esetDomainNames( ['www.your-domain.tld'] );\n```\n\n#### Multiple sub domain\n```php\n$cli-\u003esetDomainNames( ['www.your-domain.tld','ipsec.your-domain.tld'] );\n```\n\n#### Multi , different BASE \n```php\n$cli-\u003esetDomainNames( ['www.first.tld','www.second.tld'] );\n```\n\n\n### Feature: Two domain in Two DNS server into One Certificate SAN\nIf you uses two dns server , you can set dns per domain.\n\nFor example , Cert with two domain in SAN.\n\n| cert | domain                                   |\n|---|------------------------------------------|\n|commonName| example.tld                              | \n|subjectAltName| DNS:example.**tld**, DNS:example.**biz** |\n\nDNS-01 plugins for above.\n\n| Base Domain     | DNS        | plugin  | \n|-----------------|------------|---------|\n| example.**tld** | cloudflare | CloudflareDNSPlugin|\n| example.**biz** | your_own   |YourOwnPlugin|\n\nYou can use Multiple Domain DNS Server API to complete LE ACME challenge.\n\n```php\n\u003c?php\n// set dns plugin per Domain.\n$cli = new LetsEncryptAcmeDNS( 'priv_key_pem', 'your_email@gmail.com' );\n$dns_plugin_1 = new CloudflareDNSPlugin( 'cloudflare_token', 'example.tld' );\n$dns_plugin_2 = new YourOwnPlugin( 'your_own_key', 'example.biz' );\n$cli-\u003esetDnsPlugin( $dns_plugin_1, 'example.tld' );\n$cli-\u003esetDnsPlugin( $dns_plugin_2, 'example.biz' );\n```\n## How to write your Own DNS Plugin. \nCreate class and extends `DNSPlugin` class.\n```php\nclass YourOwnPlugin extends DNSPlugin{\n\n}\n```\nThen, complete implementation by your code to update DNS server.\n```php\nclass YourOwnPlugin extends DNSPlugin{\n  public function addDnsTxtRecord ( $domain, $content ): bool;{\n    // TODO: write your way to add TXT Record for ACME challenge.\n  }\n  \n  public  function removeTxtRecord ( $domain, $content ): bool{\n    // TODO: Write in your way, how to remove TXT Record , after ACME.\n  }\n}\n\n```\n\n\n## Installation.\n\nFrom GitHub.\n```bash\nrepository='php-letencrypt-acme-dns'\ncomposer config repositories.$repository \\\nvcs https://github.com/takuya/$repository  \ncomposer require takuya/$repository:master\ncomposer install\n```\n\nFrom composer packagist\n```bash\ncomposer require takuya/php-letencrypt-acme-dns\n```\n\n\n## dependencies\n```\nphp: \u003e=8.1\ncomposer:\n    \"cloudflare/sdk\": \"^1.3\",\n    \"acmephp/core\": \"^2.1\",\n    \"pear/net_dns2\": \"^1.5\",\n    \"ext-openssl\": \"*\"\n```\nFiber used. To use Fiber php8.1 required. Fiber used in waiting dns update.\n## Requirements\nTo Check DNS TXT recoed updated.\n- This package requires `Outbound UDP/53 are open`.\n\n## development \n```shell \ngit clone git@github.com:takuya/php-letencrypt-acme-dns.git\ncd php-letencrypt-acme-dns\ncomposer install \n\n## write codes, then run tests.\necho \"\nexport LE_CLOUDFLARE_TOKEN1=Bxxxxxxxx4q8mm\nexport LE_CLOUDFLARE_TOKEN2=KxxxxxxxxxxPbh\nexport LE_BASE_DOMAIN1=txxxxx.biz\nexport LE_BASE_DOMAIN2=dxxxxx.com\n\" \u003e ./env\nsource ./env\nvendor/bin/phpunit --filter CloudflarePluginTest\n```\n\n\n## Future Plan\n\nI will remove `acme/php` dependency in the future.\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakuya%2Fphp-letencrypt-acme-dns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakuya%2Fphp-letencrypt-acme-dns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakuya%2Fphp-letencrypt-acme-dns/lists"}