Giter VIP home page Giter VIP logo

php_letsencrypt's Introduction

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

Travis-ci

codecov badge

codecov

Packagist badge

Version Downloads

Github badge

Downloads Size tag license languages

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:[email protected]');

    $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);

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.

Sponsor

Author

weibo: yakeing

twitter: yakeing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.