Yikes! It’s been a little while since I update the devlog; after posting the Monthly Status Report, I had some personally impactful events occur that necessitated my taking a few days off to process. Your patience is appreciated.
Tightening the X509 ship
The big thing of note this update is I’ve sort of worked out the boundaries of what is necessary to implement to get the features that I want. It is a question of functionality vs faithfulness to the full and complete X509 spec, and it can be hard to tell what is X509 spec, and what is opinionated Botan C++ - and Botan certainly has some opinions that don’t really cross the C boundary very well.
At some point it is more sensible to encode things into a known format and then parse it rather than trying to juggle an FFI; if we cross that point, time would then be better served spent on creating / modifying a native X509 implementation while using Botan to supply cryptographic primitives instead - this would mean integrating botan more tightly with / mutually reliant on things like asn1-encoding
and crypton-x509
and crypton-x509-store
and tls
.
We aren’t at that point yet; the convenience functions in Botan serve to both limit our choices, but also make it easier to implement since there is a limit to what they expose. What we need is to be able to:
- Read and verify certificates
- Create self-signed certificates (certificate authority)
- Create and sign requests and new certificates using a certificate authority
- Create and manage certificate revocation lists
- Revoke or affirm certificates using revocation lists
- Read and write certificates and private keys to and from a certificate store
It turns out that we can get (or already have) quite a lot of this without directly implementing a few things:
- Distinguished names are fancy multimaps / key-value lists, and can be represented in an encoded string format rather than constructing a map object and passing it around. However, it is worth noting that there is logic attached to what keys and values are ‘valid’. Ultimately, it may eventually become useful to fully implement, but right now the cost/opportunity balance is against it.
- creating extensions is obviated by the ‘options’ struct, and by implication of supplied arguments in the wrapping functions - in other words, the extensions objects are not used directly but are instead created on-the-fly and immediately consumed. However, this makes querying the finished objects for extensions difficult - they are represented via an abstract class, and having a pointer to that is slightly complicated especially when we don’t know what subclass it is (I am looking into how private keys manage it). If I can get the abstract vs subclass stuff working, it may be worth implementing anyway, due to functions that allow us to query certificates and other objects for their related extensions
- Path validation has already been ‘handled’ by the
botan_x509_cert_verify_with_crl
which serves to encapsulate the necessary logic to callBotan::x509_path_validate
and return the validity. Like distinguished names, it may be worth implementing fully eventually, but at the moment time is better spent elsewhere.
As a result, I may end up temporarily or permanently axing the X509 DN, Extensions, and Path modules. This shrinks our implementation surface a little, and allows us to keep focused on implementing what is necessary to get the desired functionality. So we don’t get everything we wanted, but its still a vast improvement on the basic X509 FFI that I started with, and we can focus on completeness later if that direction still favorable. It is okay to write code that you don’t end up using, it is a problem if you keep that code to your detriment.
This means we can focus on the remaining items for X509:
- PEM and DER encoding for X509 more objects
- Finishing the Cert Authority and new CRL function C++ implementations
- A bunch of small encoding things
Codewise, this update features new functions for creating, querying, and updating certificate revocation lists, which before could only be read from a file. They’re still in progress, but huzzah!
I also got the sqlite3 certificate store working; this necessitates configuring botan using the --with-sqlite3
flag, but it should be working now.
The repo and upstream fork have been updated.