genkgo/php-asn1
Encode and decode arbitrary ASN.1 structures in PHP using ITU-T X.690 (DER/BER). Build or parse X.509/PKI data like CSRs, certificates, and CRLs, manipulate objects, then re-encode. Requires supported PHP plus gmp or bcmath.
TemplateParser), making it versatile for both custom binary formats and standardized protocols.gmp/bcmath (for large integer handling).curl for OID name resolution (can be mocked or disabled).BLOB fields or API responses).TemplateParser to enforce schemas).\Exception on malformed input (e.g., invalid BER/DER).Log facade.TemplateParser strictly; sanitize external binary data.filesystem:disk).spatie/asn1) or native tools (e.g., OpenSSL CLI for simple tasks).// config/app.php
'providers' => [
App\Providers\ASN1ServiceProvider::class,
];
// App\Providers\ASN1ServiceProvider.php
public function register() {
$this->app->singleton('asn1', function () {
return new \FG\ASN1\ASNObject();
});
}
// App\Facades\ASN1.php
public static function decode($binaryData) {
return \FG\ASN1\ASNObject::fromBinary($binaryData);
}
public function __construct(private ASN1 $asn1) {}
openssl x509 -in cert.der -text).Integer::getBinary()).TemplateParser to enforce schemas in API request validation.spatie/asn1).v2.8.0+ to avoid PHP 8.0 deprecations.Asn1Decoded, Asn1DecodeFailed).Mockery to stub ASN.1 objects in unit tests.Universal classes.openssl_csr_new() with custom ASN.1 construction.// app/Http/Middleware/ValidateAsn1Payload.php
public function handle($request, Closure $next) {
$binary = base64_decode($request->input('asn1_payload'));
$asn1 = \FG\ASN1\ASNObject::fromBinary($binary);
// Validate structure with TemplateParser
return $next($request);
}
use FG\ASN1\TemplateParser;
$template = [/* ... */];
$parser = new TemplateParser();
$parser->parseBinary($request->asn1_data, $template);
app/ASN1/Extensions/YourType.php).ASNObject::fromBinary()) to add Laravel-specific logging.SequenceTest.php).How can I help you explore Laravel packages today?