PHPackages                             stayallive/certificate-chain-resolver - 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. stayallive/certificate-chain-resolver

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

stayallive/certificate-chain-resolver
=====================================

Certificate chain resolver.

v1.0.2(4y ago)21.1k[1 issues](https://github.com/stayallive/certificate-chain-resolver/issues)MITPHPPHP ^8.0

Since Mar 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/stayallive/certificate-chain-resolver)[ Packagist](https://packagist.org/packages/stayallive/certificate-chain-resolver)[ Docs](https://github.com/stayallive/certificate-chain-resolver)[ GitHub Sponsors](https://github.com/stayallive)[ RSS](/packages/stayallive-certificate-chain-resolver/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

Certificate Chain Resolver
==========================

[](#certificate-chain-resolver)

[![Latest Version](https://camo.githubusercontent.com/6a9febf57f4b9caba7bfca8ff2614d8330d2e7363b25bcb0a35d18803b568d8e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73746179616c6c6976652f63657274696669636174652d636861696e2d7265736f6c7665722e7376673f7374796c653d666c61742d737175617265)](https://github.com/stayallive/certificate-chain-resolver/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/818b51102be7095f6e7aae5c3c10ad020cfcbb4a5f9d8ae05d69b0ce1a2b795c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73746179616c6c6976652f63657274696669636174652d636861696e2d7265736f6c7665722f63692e79616d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/stayallive/certificate-chain-resolver/actions/workflows/ci.yaml)[![Total Downloads](https://camo.githubusercontent.com/4d8637057956a65a226debf21d6b59fc60cd8c9a659a54f09e97a4e49c8418d7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73746179616c6c6976652f63657274696669636174652d636861696e2d7265736f6c7665722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stayallive/certificate-chain-resolver)

Resolve a certificate chain with a simple to use interface.

A hosted version using this package can be found here: [chief.tools/certificate-chain-resolver](https://chief.tools/certificate-chain-resolver?ref=github).

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

[](#installation)

```
composer require stayallive/certificate-chain-resolver
```

Usage
-----

[](#usage)

You can use `Resolver::fetchForCertificate` to retrieve the full PEM encoded chain as a string.

```
$output = \Stayallive\CertificateChain\Resolver::fetchForCertificate(
    \Stayallive\CertificateChain\Certificate::loadFromPathOrUrl('path/to/certificate.pem')
);
```

You can use `Certificate::loadFromPathOrUrl` to retrieve a `Certificate` instance you need for constructing a `Resolver` instance.

The certificate is fetched using `file_get_contents` so any path or URL that is supported by `file_get_contents` should work.

The `Certificate` can be in multiple formats and encodings, currently supported: PEM, DER and PKCS7, they are all normalized to PEM encoding.

If you need the chain without the original certificate or want to get an array of `Certificate` instances representing the chain you can use the `Resolver` class directly:

```
$chain = new \Stayallive\CertificateChain\Resolver(
    \Stayallive\CertificateChain\Certificate::loadFromPathOrUrl('path/to/certificate.pem')
);

$chain->getContents(); // Same as `Resolver::fetchForCertificate`, returns a string
$chain->getCertificates(); // Array of certificates in the chain, returns an array

// Versions that do not include the certificate that was used to construct the `Resolver` with
$chain->getContentsWithoutOriginal();
$chain->getCertificatesWithoutOriginal();
```

There are 2 possible exceptions that are thrown while retrieving the certificate or it's chain, they both extend `ResolverException`:

- `CouldNotLoadCertificate` - this indicates fetching the certificate from an URL or path failed
- `CouldNotParseCertificate` - this indicates parsing the fetched certificate failed because it's invalid or it's encoding is unsupported

Background: the trust chain
---------------------------

[](#background-the-trust-chain)

All operating systems contain a set of default trusted root certificates. But Certificate Authorities usually don't use their root certificate to sign customer certificates. Instead of they use so called intermediate certificates, because they can be rotated more frequently.

A certificate can contain a special Authority Information Access extension (RFC-3280) with URL to issuer's certificate. Most browsers can use the AIA extension to download missing intermediate certificate to complete the certificate chain. This is the exact meaning of the Extra download message. But some clients, mostly mobile browsers, don't support this extension, so they report such certificate as untrusted.

This results in 'untrusted'-warnings since the browser thinks you are on an insecure connection.

A server should always send a complete chain, which means concatenated all certificates from the certificate to the trusted root certificate (exclusive, in this order), to prevent such issues. So when installing a SSL certificate on a server you should install all intermediate certificates as well. You should be able to fetch intermediate certificates from the issuer and concat them together by yourself.

This package helps you automatize that boring task by looping over certificate's AIA extension field and returning the full chain to you.

Credits
-------

[](#credits)

This package was originally created as a fork of [ssl-certificate-chain-resolver](https://github.com/spatie/ssl-certificate-chain-resolver) written by [Spatie](https://github.com/spatie) which was inspired by [cert-chain-resolver](https://github.com/zakjan/cert-chain-resolver/) written by [Jan Žák](http://www.zakjan.cz/). Some text, mainly the background about the trust chain, was copied from the readme of his repo.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover a security vulnerability within this package, please send an e-mail to Alex Bouma at `alex+security@bouma.me`. All security vulnerabilities will be swiftly addressed.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~14 days

Total

3

Last Release

1550d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1090754?v=4)[Alex Bouma](/maintainers/stayallive)[@stayallive](https://github.com/stayallive)

---

Top Contributors

[![stayallive](https://avatars.githubusercontent.com/u/1090754?v=4)](https://github.com/stayallive "stayallive (19 commits)")

---

Tags

certificatecertificate-chainhttpshttpscertificatecertificate-chain

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/stayallive-certificate-chain-resolver/health.svg)

```
[![Health](https://phpackages.com/badges/stayallive-certificate-chain-resolver/health.svg)](https://phpackages.com/packages/stayallive-certificate-chain-resolver)
```

###  Alternatives

[composer/ca-bundle

Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.

3.0k358.5M250](/packages/composer-ca-bundle)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

749284.3k37](/packages/civicrm-civicrm-core)[kelunik/certificate

Access certificate details and transform between different formats.

11043.2M12](/packages/kelunik-certificate)[phpseclib/phpseclib2_compat

phpseclib 2.0 polyfill built with phpseclib 3.0

132.0M16](/packages/phpseclib-phpseclib2-compat)[mlocati/ocsp

Library to query HTTPS Certificates revocation status using the Online Certificate Status Protocol (OCSP)

40773.8k2](/packages/mlocati-ocsp)[spatie/ssl-certificate-chain-resolver

SSL certificate chain resolver

30610.3k](/packages/spatie-ssl-certificate-chain-resolver)

PHPackages © 2026

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