https://github.com/sasha-bo/self-signed-certs
PHP library for creating domain self-signed certificate
https://github.com/sasha-bo/self-signed-certs
certificates https nginx openssl php self-signed self-signed-certificate ssl ssl-certificates
Last synced: 2 months ago
JSON representation
PHP library for creating domain self-signed certificate
- Host: GitHub
- URL: https://github.com/sasha-bo/self-signed-certs
- Owner: sasha-bo
- License: gpl-3.0
- Created: 2023-10-08T11:29:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-22T10:05:57.000Z (over 1 year ago)
- Last Synced: 2024-04-24T00:27:26.630Z (about 1 year ago)
- Topics: certificates, https, nginx, openssl, php, self-signed, self-signed-certificate, ssl, ssl-certificates
- Language: PHP
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# self-signed-certs
PHP library for creating self-signed certificates. No dependencies.
### Installation
`composer require sashabo/self-signed-certs`
## Usage
```php
setName('Some Name')
->setEmail('[email protected]')
->setAddress('CC', 'State or province', 'City')
->setOrganization('Organization', 'Department')
;$pair = $generator->generate();
$pair->save('/etc/nginx/ssl/my.key', '/etc/nginx/ssl/my.crt');
```### CertificateGenerator methods:
`generate(): CertificatePair`
These settings are not necessary, you may use defaults in most cases:
`setExpireDays(int $days): static` - 3650 by default
`setPrivateKeyBits(int $bits): static` - 4096 by default
`setPrivateKeyType(int $type): static` - OPENSSL_KEYTYPE_RSA by default
`setDigestAlgorithm(string $algorithm): static` - AES-128-CBC by default
`setOpenSslConfPath(string $path): static` - /etc/ssl/openssl.cnf by default
(standard path for Ubuntu and most of linuxes)These settings override openssl.cnf settings:
`setName(string $name): static`
`setEmail(string $email): static`
`setAddress(string $countryCode, string $stateOrProvince, string $city): static`
`setOrganization(string $name, string $unit): static`
### CertificatePair methods:
`getPrivateKey(): \OpenSSLAsymmetricKey`
`getCertificate(): \OpenSSLCertificate`
`exportPrivateKey(?string $passPhrase = null): string`
`exportCertificate(): string`
`save(string $privateKeyPath, string $certPath, ?string $passPhrase = null): void`