You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.
This library makes it easy to create encoded structures, but when it comes to parsing them, I'm a little unsure about the best way.
I have been imperatively checking the type of each element in the structure after doing Object::fromBinary().
I wondered if it's possible to do anything similar to this, and parse a structure according to a template? If not I might take a look at PRing something for this.
I notice some of the structures have optional parameters (eg, tbsCertificateInfo), so I'd hope to handle that also.
So far I recommend defining a class for the thing you want to parse then move the parsing logic into there (including checking types etc) (check X509/CertificateSubject if you haven't already).
This gives you full error handling capacities, you can handle optional arguments and have full type savety with phpdoc.
The idea of defining templates sounds interesting because it can remove the necessity for the boiler plate code. However, the approach you suggested would only work if I would change the constructors to always accept no arguments which I would rather not do. Instead we could have a nested nested array of type identifiers to define such a template.
If you have yet another idea on how to traverse parsed objects while maintaining type savety and error handling I am all ears :)
I was also thinking about writing a ASN.1 compiler which could take a ASN.1 definition and compile php code which uses PHPASN1 from that. This would be a separate repository though.
This library makes it easy to create encoded structures, but when it comes to parsing them, I'm a little unsure about the best way.
I have been imperatively checking the type of each element in the structure after doing
Object::fromBinary()
.I wondered if it's possible to do anything similar to this, and parse a structure according to a template? If not I might take a look at PRing something for this.
I notice some of the structures have optional parameters (eg, tbsCertificateInfo), so I'd hope to handle that also.
The text was updated successfully, but these errors were encountered: