exonet / certificate-converter
PHP package to convert an SSL certificate to various formats (e.g PKC12, PEM).
Installs: 7 883
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 8
Forks: 1
Open Issues: 0
Requires
- php: ~7.1|^8.0|^8.1
- ext-openssl: *
- ext-zip: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8.0
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-10-23 04:23:59 UTC
README
PHP package to convert an SSL certificate to various formats (e.g PKC12, PEM).
Install
Via Composer
$ composer require exonet/certificate-converter
Example usage
The example below shows how combine separate contents of a certificate to a combined PEM string.
crt
The certificate (typically the contents of.crt
file).key
The private key (typically the contents of the.key
file)ca bundle
The certificate of the intermediate and/or the trusted root certificate
// Initialise a new certificate converter. $converter = new Converter(); // Setup the plain format class that should be converted. $plain = new Plain(); $plain ->setKey('-----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY----- ') ->setCrt('-----BEGIN CERTIFICATE----- ... -----END CERTIFICATE----- ') ->setCaBundle('-----BEGIN CERTIFICATE----- ... -----END CERTIFICATE----- '); // Convert the plain certificate to PEM. $pem = $converter ->from($plain) ->to(new Pem()); // Save as zip file. $pem->asZip('./'); // Get an array with the certificate files: print_r($pem->asFiles()); // Get the certificate as string: print_r($pem->asString());
Change log
Please see releases for more information on what has changed recently.