spomky-labs/pki-framework
PHP 8.1+ framework for Public Key Infrastructure: X.509 certificates (incl. attribute certs), ASN.1 DER encoding/decoding, X.501/X.520 DN parsing, PEM (RFC 7468) handling, and PKCS-oriented cryptography utilities.
php artisan commands for certificate rotation).Certificate, CertificateRevocationList, AlgorithmIdentifier) enables selective adoption (e.g., use only ASN.1 parsing without full CA functionality).PKIServiceProvider) to bind interfaces to implementations.PKI::generateCertificate()) via facades for cleaner code.pki:issue, pki:revoke).brick/math (for cryptography) and phpseclib (optional). Test for conflicts with Laravel’s ext-openssl or ext-gmp.| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Cryptographic Complexity | ASN.1/DER parsing and PKCS#11/12 operations are error-prone. Misconfigurations (e.g., weak key sizes, improper revocation) could expose systems. | - Audit Dependencies: Verify brick/math and phpseclib versions for vulnerabilities. |
| - Validation Tests: Implement unit tests for certificate chains, CRL parsing, and OCSP responses using the framework’s built-in test suite as a template. | ||
| Key Management | No built-in HSM or secure storage for private keys. Keys stored in PHP files or Laravel config risk exposure. | - Integrate with Laravel Vault (e.g., laravel/vault) or AWS KMS for key storage. |
| Performance | ASN.1 parsing/encoding is CPU-intensive. May bottleneck high-volume validation (e.g., 10K+ certificates/sec). | - Benchmark: Test with openssl speed and compare against ext-openssl. |
| - Caching: Cache parsed certificates (e.g., Redis) to avoid reprocessing. | ||
| Revocation Overhead | CRL/OCSP checks add latency. Poorly optimized revocation lists could degrade performance. | - Delta CRLs: Use incremental updates for large CRLs. |
| Laravel-Specific Gaps | No native support for Laravel’s queue workers, events, or notifications. Manual integration required for async workflows (e.g., certificate expiration alerts). | - Event-Driven Design: Dispatch CertificateIssued, CertificateRevoked events to trigger queues/notifications. |
| Future-Proofing | PHP’s cryptographic ecosystem evolves (e.g., libsodium, libressl). Risk of framework stagnation if upstream (original sop repo) is abandoned. |
- Monitor Upstream: Track sop repo activity. Fork if maintenance lags. |
| Compliance Gaps | No built-in audit logging or FIPS 140-2 validation. Critical for regulated industries (e.g., healthcare, finance). | - Layer on Laravel Logging: Log all PKI operations to a SIEM (e.g., Splunk, ELK). |
- FIPS Compliance: Use ext-openssl with FIPS mode or integrate with a FIPS-certified HSM. |
Use Case Clarity:
Key Management:
Performance Requirements:
Integration Depth:
Compliance:
Team Expertise:
Long-Term Maintenance:
| Laravel Component | Integration Strategy | Example Implementation |
|---|---|---|
| Service Container | Register the PKI framework as a Laravel service provider to bind interfaces (e.g., CertificateManager) to the framework’s classes. |
```php |
| // app/Providers/PKIServiceProvider.php | ||
| public function register() | ||
| { |
$this->app->singleton(CertificateManager::class, function ($app) {
return new SpomkyLabs\PKI\CertificateManager();
});
}
| **Facades** | Create facades for common operations (e.g., `PKI::generate()`, `PKI::validate()`) to simplify usage. | ```php
// app/Facades/PKI.php
public static function generateCertificate(array $config): Certificate
{
return app(CertificateManager::class)->generate($config);
}
``` |
| **Artisan Commands** | Extend with custom commands for certificate lifecycle management (e.g., issuance, revocation, rotation). | ```php
// app/Console/Commands/IssueCertificate.php
public function handle()
{
$cert = PKI::generateCertificate($this->options());
$cert->saveToFile(storage_path('certs/issued/'.$cert->getSerialNumber().'.pem'));
}
``` |
| **Task Scheduling** | Use Laravel’s scheduler to automate certificate rotation/renewal (e.g., `php artisan pki:rotate --days=30`). | ```php
// app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
$schedule->command('pki:rotate')->dailyAt('03:00');
}
``` |
| **Queue Workers** | Offload revocation checks (CRL/OCSP) to queues to avoid blocking requests. | ```php
// app/Jobs/ValidateCertificate.php
public function handle()
{
$cert = PKI::loadFromFile($this->path);
if (!PKI::validate($cert)) {
// Dispatch revocation or alert
}
}
``` |
| **Events** | Dispatch events for certificate lifecycle changes (e.g., `CertificateIssued`, `CertificateRevoked`) to trigger notifications or side effects.
How can I help you explore Laravel packages today?