voltone / x509

Elixir package for working with X.509 certificates, Certificate Signing Requests (CSRs), Certificate Revocation Lists (CRLs) and RSA/ECC key pairs
BSD 3-Clause "New" or "Revised" License
120 stars 28 forks source link

chore: simplify record expansion #58

Closed victorolinasc closed 1 year ago

victorolinasc commented 1 year ago

I think the approach used on the x509.ASN1 file to expand and work with records of the public_key application is awesome. Truly simplified a lot of things!

I've came up with a simplified way to do the same expansions with a bit less code and one that will expand all records at once. Just this module could be a library in and on itself but I after thinking a lot about it, my opinion is that x509 is becoming a mandatory dependency for all libraries working with :crypto and :public_key.

Feel free to simply ignore this PR and close it. It is just that if I depend on x509 and then depend on other records I would make a separate ASN1 module with the code in this PR.

victorolinasc commented 1 year ago

Well... it seems my approach does not work reliably on Elixir 1.11, 1.10 and that it simply fails on 1.9 and before... That surprised me :)

So... will think a bit more about it... either way, it was awesome to read this code along.

Thanks anyway and sorry for the noise here!

voltone commented 1 year ago

I've been meaning to get rid of the ASN1 module completely. The idea is to implement the core functionality of this library in Erlang (including a Rebar3 file to allow Erlang projects to depend on this package without requiring Elixir). There would still be Elixir modules and a Mix file as well, which would provide some Elixir-specific functionality for e.g. working with DateTime structs. The advantage, besides making the library accessible for Erlang users, is that all the OID macro and Erlang record handling could be implemented entirely in Erlang.