PHPackages                             adaopedro/php-openssl-proxy - 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. adaopedro/php-openssl-proxy

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

adaopedro/php-openssl-proxy
===========================

A PHP wrapper around the OpenSSL extension that provides a user-friendly interface for dealing with OpenSSL

5111PHP

Since Jan 31Pushed 4y ago1 watchersCompare

[ Source](https://github.com/AdaoPedro/php-openssl-proxy)[ Packagist](https://packagist.org/packages/adaopedro/php-openssl-proxy)[ RSS](/packages/adaopedro-php-openssl-proxy/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

php-openssl-proxy
=================

[](#php-openssl-proxy)

About
-----

[](#about)

A PHP wrapper around the OpenSSL extension that provides a user-friendly interface for dealing with OpenSSL.

What's up with the "proxy" name?
--------------------------------

[](#whats-up-with-the-proxy-name)

It is simply an analogy of the role of a proxy server - which acts as an intermediary.

Features
--------

[](#features)

Create X.509, CSRs and CRLs certificates, Create RSA, HD and DSA keys, Generate and verify signatures, Encoding and decoding, Parsing x509 certificate.

Requirements
------------

[](#requirements)

This library needs PHP 8 or greater, ext-openssl.

Installation
------------

[](#installation)

```
composer require adaopedro/php-openssl-proxy @dev
```

Example Usage
-------------

[](#example-usage)

### Creating a Self-Signed Certificate

[](#creating-a-self-signed-certificate)

```
use AdaoPedro\OpenSSLProxy\SSCertificate;

$ssCertificate = (new SSCertificate(
    days: 365, //expiration
))->setDistinguishNames(
        countryName: "AO",
        stateOrProvinceName: "Angola",
        localityName: "Luanda",
        organizationName: "A Pedro Developers (SU), Lda",
        organizationalUnitName: "AP",
        commonName: "apedrodevelopers",
        emailAddress: "contato@apdev.ao"
);

try {
    $ssCertificate->save();
} catch(\Exception $ex) {
    echo $ex->getMessage() . PHP_EOL;
}
```

### Creating a CA-Signed Certificate

[](#creating-a-ca-signed-certificate)

```
use AdaoPedro\OpenSSLProxy\CASCertificate;

$certificate = (new CASCertificate(
    days: 365, //expiration
    rootCertificate: $rootCertificate, //an instance of a Self-Signed Certificate, for example
))->setDistinguishNames(
        //...
);

try {
    $certificate->save();
} catch(\Exception $ex) {
    echo $ex->getMessage() . PHP_EOL;
}
```

### Exporting a certificate as a string

[](#exporting-a-certificate-as-a-string)

```
//$certificate => an instance of SS or CAS Certificate
echo $certificate->getx509();
```

### Exporting a certificate as an PHP OpenSSLCertificate object

[](#exporting-a-certificate-as-an-php-opensslcertificate-object)

```
//$certificate => an instance of SS or CAS Certificate
var_dump(
    $certificate->get()
);
```

### Exporting public and private keys from a certificate

[](#exporting-public-and-private-keys-from-a-certificate)

```
 //$certificate => an instance of SS or CAS Certificate
var_dump(
    $certificate->getPublicKey(),
);

//$certificate => an instance of SS or CAS Certificate
var_dump(
    $certificate->getPrivateKey(),
);

var_dump(
    $certificate->getPrivateKeyDecrypted() //in case we're working with encrypt_key
);
```

### Generating public and private keys

[](#generating-public-and-private-keys)

```
$pKey = \AdaoPedro\OpenSSLProxy\generateNewPKey();

list($privKey, $pubKey) = \AdaoPedro\OpenSSLProxy\exportKeysFrom($pKey);

echo $pubKey . PHP_EOL;
echo $privKey . PHP_EOL;
```

### Signing

[](#signing)

```
$data = "Hello world!!";

$signature = \AdaoPedro\OpenSSLProxy\getSignatureFrom(
    $data,
    file_get_contents(".../private_key.pem"),
);
```

### Signature verification

[](#signature-verification)

```
$data = "Hello world!!";

echo
\AdaoPedro\OpenSSLProxy\verifySignatureOf(
    $data,
    file_get_contents(".../hash.dat"),
    file_get_contents(".../public_key.pem"),
) === true
? "Verified"
: "Error. Data modified";
```

### Parsing a PHP OpenSSLCertificate certificate object

[](#parsing-a-php-opensslcertificate-certificate-object)

```
//$certificate => an instance of SS or CAS Certificate
var_dump(
    $certificate()
);
```

### Checks if a private key corresponds to a certificate

[](#checks-if-a-private-key-corresponds-to-a-certificate)

```
echo
\AdaoPedro\OpenSSLProxy\checkIfPrivateKey(
    file_get_contents(".../private_key.pem")
)->correspondsTo(
    file_get_contents(".../cert.pem")
) === true
? "Yes. It does"
: "No. It does not";
```

### Customizing OpenSSL configurations (in case when we're using certificate generator classes)

[](#customizing-openssl-configurations-in-case-when-were-using-certificate-generator-classes)

```
use AdaoPedro\OpenSSLProxy\SSCertificate;

//you can find the initial config file in root of lib directory
/*
To customize, just pass the config filename as second parameter to SSCertificate constructor
or third parameter in case of CASCertificate
*/

$certificate = (new SSCertificate(
    days: 365, //expiration
    configFilename: __DIR__ . "/openssl_configs.php"
))->setDistinguishNames(
        //...
);
```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d252512f6551f65550207a8de9c8617112b4f6ca28800851c4599cf873706f6d?d=identicon)[adaopedro](/maintainers/adaopedro)

---

Top Contributors

[![adaopedro](https://avatars.githubusercontent.com/u/30510167?v=4)](https://github.com/adaopedro "adaopedro (11 commits)")

### Embed Badge

![Health badge](/badges/adaopedro-php-openssl-proxy/health.svg)

```
[![Health](https://phpackages.com/badges/adaopedro-php-openssl-proxy/health.svg)](https://phpackages.com/packages/adaopedro-php-openssl-proxy)
```

###  Alternatives

[dflydev/dot-access-data

Given a deep data structure, access data by dot notation.

720359.1M86](/packages/dflydev-dot-access-data)[symfony/webpack-encore-bundle

Integration of your Symfony app with Webpack Encore

95363.0M496](/packages/symfony-webpack-encore-bundle)[scrivo/highlight.php

Server side syntax highlighter that supports 185 languages. It's a PHP port of highlight.js

71140.3M82](/packages/scrivo-highlightphp)[rioastamal/terbilang

Sebuah pustaka untuk menterjemahkan angka ke dalam bilangan Bahasa Indonesia

442.3k](/packages/rioastamal-terbilang)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
