Skip to content
EasyRSA3 wrapper for PHP
PHP
Branch: master
Clone or download

Latest commit

Latest commit 1e22940 Sep 17, 2019

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Create FUNDING.yml Sep 17, 2019
examples show content of certs Sep 1, 2018
src show content of certs Sep 1, 2018
.gitignore init Aug 30, 2018
.scrutinizer.yml init Aug 30, 2018
.travis.yml init Aug 30, 2018
LICENSE init Aug 30, 2018
README.md show content of certs Sep 1, 2018
composer.json refactoring for more stable work Aug 31, 2018

README.md

Latest Stable Version Build Status Total Downloads License PHP 7 ready Code Climate Scrutinizer CQ

EasyRSA wrapper for PHP

composer require evilfreelancer/easyrsa-php

How to use

More examples you can find here.

Download latest release of EasyRSA

Before you start use this script need to download the easyrsa package.

<?php
require_once __DIR__ . '/../vendor/autoload.php';

use \EasyRSA\Config;
use \EasyRSA\Downloader;

$config =
    (new Config())
        ->setFolder('./easy-rsa')
        ->setArchive('./easy-rsa.tar.gz');

$dnl = new Downloader($config);
$dnl->getEasyRSA();

Result of this script will be in easy-rsa folder.

Generate certificates

<?php
require_once __DIR__ . '/../vendor/autoload.php';

// Load dotenv?
if (file_exists(__DIR__ . '/vars.example')) {
    (new Dotenv\Dotenv(__DIR__, 'vars.example'))->load();
}

use \EasyRSA\Config;
use \EasyRSA\Wrapper;

$config =
    (new Config())
        ->setFolder('./easy-rsa')
        ->setCertsFolder('./easy-rsa-certs')
        ->setArchive('./easy-rsa.tar.gz');

$wrp = new Wrapper($config);
$wrp->init_pki();
$wrp->build_ca(true);
$wrp->gen_dh();
$wrp->build_server_full('server', true);
$wrp->build_client_full('client1', true);
$wrp->build_client_full('client2', true);

Result of this script will be in easy-rsa-certs folder.

List of all Wrapper methods

Main methods

  • init_pki()
  • build_ca(bool $nopass = false)
  • gen_dh()
  • gen_req(string $name, bool $nopass = false)
  • sign_req_client(string $filename)
  • sign_req_server(string $filename)
  • build_client_full(string $name, bool $nopass = false)
  • build_server_full(string $name, bool $nopass = false)
  • revoke(string $filename)
  • gen_crl()
  • update_db()
  • show_req(string $filename)
  • show_cert(string $filename)
  • import_req(string $filename)
  • export_p7(string $filename)
  • export_p12(string $filename)
  • set_rsa_pass(string $filename)
  • set_ec_pass(string $filename)

Optional method

  • getContent() - Show content of any certificates what was created
<?php
require_once __DIR__ . '/../vendor/autoload.php';

use \EasyRSA\Config;
use \EasyRSA\Wrapper;

$config =
    (new Config())
        ->setCerts('./easy-rsa-certs')
        ->setScripts('./easy-rsa')
        ->setArchive('./easy-rsa.tar.gz');

$wrp = new Wrapper($config);

$file = $wrp->getContent('ca.crt');
echo "$file\n";

$file = $wrp->getContent('server.crt');
echo "$file\n";

$file = $wrp->getContent('server.key');
echo "$file\n";

Links

You can’t perform that action at this time.