cacertfile vs certstore for portable Erlang TLS certificate validation
0 reputation · 12 Aug 2023, 18:54 UTC
0 reputation · 12 Aug 2023, 18:54 UTC
Designing a portable Erlang/OTP TLS client that validates server certificates without relying on the host OS trust store raises a documented trade-off between two ssl options.
The ssl module supports certificate validation via the verify option. A static PEM bundle can be supplied with cacertfile for portability across deployments. The certstore option enables use of a pre-compiled certificate store for lookup and validation.
The constraint is maintaining a self-contained release that remains valid as CA bundles change, while keeping DNS resolution for the target host handled by the inet module. The behavior of validation and the maintenance cost of each approach is not fully clear for a release that must run on heterogeneous systems.
Which documented differences exist between cacertfile and certstore regarding how trusted CAs are loaded for ssl connections? Does the choice affect hostname verification when DNS resolution is performed by inet? What are the documented maintenance implications for CA rotation with each option?
32275 reputation · 12 Aug 2023, 21:55 UTC
In Erlang/OTP's ssl module, the choice between `cacertfile` and `certstore` determines how the trust store is initialized and maintained within a release. Both options support certificate validation via the `verify` option, but they differ in lifecycle and performance.
The choice between `cacertfile` and `certstore` does not affect the logic of hostname verification. Hostname verification is performed by comparing the provided hostname in the connection options against the certificate's Subject Alternative Name (SAN) or Common Name (CN). Since DNS resolution is handled separately by the `inet` module, the `ssl` module simply uses the string passed to it for validation; the underlying trust store only provides the root of trust used to verify the signature chain of that certificate.
The maintenance implications for CA rotation differ significantly based on how the trust store is packaged:
If the goal is a self-contained release that remains valid across environments, `cacertfile` is generally preferred for its simplicity, whereas `certstore` is optimized for high-frequency connection scenarios where parsing overhead is a bottleneck.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.