PHPackages                             evilfreelancer/easyrsa-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. evilfreelancer/easyrsa-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

evilfreelancer/easyrsa-php
==========================

An easy way to use the official EasyRSA collection of shell scripts in your application

1.0.2(5mo ago)71.4k2[2 issues](https://github.com/EvilFreelancer/easyrsa-php/issues)MITPHPPHP ^7.2|^8.0

Since Aug 30Pushed 5mo ago3 watchersCompare

[ Source](https://github.com/EvilFreelancer/easyrsa-php)[ Packagist](https://packagist.org/packages/evilfreelancer/easyrsa-php)[ Patreon](https://www.patreon.com/efreelancer)[ RSS](/packages/evilfreelancer-easyrsa-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (9)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/1a19569490f8800689a10e0749c67c797ce7faa81c92919d0d4be12d41330a9e/68747470733a2f2f706f7365722e707567782e6f72672f6576696c667265656c616e6365722f656173797273612d7068702f762f737461626c65)](https://packagist.org/packages/evilfreelancer/easyrsa-php)[![Total Downloads](https://camo.githubusercontent.com/084deb6f3ac1a4063c499a6adbcb19bf8114d4252421add2db8438609497131f/68747470733a2f2f706f7365722e707567782e6f72672f6576696c667265656c616e6365722f656173797273612d7068702f646f776e6c6f616473)](https://packagist.org/packages/evilfreelancer/easyrsa-php)[![Build Status](https://camo.githubusercontent.com/308ad845922fe9526ddc98512e5eccd28018e2727a3ee48cc3c84781fb893437/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4576696c467265656c616e6365722f656173797273612d7068702f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/EvilFreelancer/easyrsa-php/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/438dcc2b4bc8dc32622da515a75d9e553558ac57319bb7552027deb1d8f4ee2c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4576696c467265656c616e6365722f656173797273612d7068702f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/EvilFreelancer/easyrsa-php/?branch=master)[![Code Climate](https://camo.githubusercontent.com/f1b62d40d3954edd91d85cd4f261f33402bfa2435516b507cbb9a7179c6291ba/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f4576696c467265656c616e6365722f656173797273612d7068702f6261646765732f6770612e737667)](https://codeclimate.com/github/EvilFreelancer/easyrsa-php)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c5a760c86a405f63ee00e26cd34c920379ed9a14ca20ba3aaa4176965eab3704/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4576696c467265656c616e6365722f656173797273612d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/EvilFreelancer/easyrsa-php/?branch=master)[![License](https://camo.githubusercontent.com/fdc5c4683f1a6b7100b9ae1f066e86aeb21f11f54f105abfa27786f4e63a5bd6/68747470733a2f2f706f7365722e707567782e6f72672f6576696c667265656c616e6365722f656173797273612d7068702f6c6963656e7365)](https://packagist.org/packages/evilfreelancer/easyrsa-php)

EasyRSA wrapper for PHP
=======================

[](#easyrsa-wrapper-for-php)

An easy way to use the [official EasyRSA](https://github.com/OpenVPN/easy-rsa) collection of shell scripts in your application.

```
composer require evilfreelancer/easyrsa-php

```

By the way, EasyRSA library support Laravel and Lumen frameworks, details [here](#frameworks-support).

How to use
----------

[](#how-to-use)

More examples you can find [here](examples).

### Download the latest release of EasyRSA

[](#download-the-latest-release-of-easyrsa)

Before you start use this script need to download the [easy-rsa](https://github.com/OpenVPN/easy-rsa) package.

```
require_once __DIR__ . '/../vendor/autoload.php';

use EasyRSA\Downloader;

$dnl = new Downloader([
    'archive' => './easy-rsa.tar.gz',
    'scripts' => './easy-rsa',
]);

$dnl->getEasyRSA();
```

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

### Generate certificates

[](#generate-certificates)

```
require_once __DIR__ . '/../vendor/autoload.php';

use Dotenv\Dotenv;
use EasyRSA\Commands;

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

$cmd = new Commands([
    'scripts' => './easy-rsa',
    'certs'   => './easy-rsa-certs',
]);

$cmd->initPKI();
$cmd->buildCA(true);
$cmd->genDH();
$cmd->buildServerFull('server', true);
$cmd->buildClientFull('client1', true);
$cmd->buildClientFull('client2', true);
```

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

### List of all available commands

[](#list-of-all-available-commands)

MethodDescriptiongetContent(string $filename)Show content of any certificate available in "certs" folderinitPKI()Instantiate Public Key Infrastructure (PKI)buildCA(bool $nopass = false)Build Certificate Authority (CA)genDH()Generate Diffie-Hellman certificate (DH)genReq()Generate request for certificatesignReqClient(string $filename)Sign request for client certificatesignReqServer(string $filename)Sign request for server certificatebuildClientFull(string $name, bool $nopass = false)Build public and private key of clientbuildServerFull(string $name, bool $nopass = false)Build public and private key of serverrevoke(string $filename)Revoke certificategenCRL()Generate Certificate Revocation List (CRL)updateDB()Update certificates databaseshowCert(string $filename)Display information about certificateshowReq(string $filename)Display information about requestimportReq(string $filename)Import requestexportP7(string $filename)Export file in format of Public-Key Cryptography Standards (PKCS) v7 (P7)exportP12(string $filename)Export file in format of Public-Key Cryptography Standards (PKCS) v12 (P12)setRSAPass(string $filename)Set password in Rivest–Shamir–Adleman (RSA) formatsetECPass(string $filename)Set password in Elliptic Curve (EC) formatYou also can read content of generated certificate via `getConfig($filename)` method:

```
