macula_trust_store (macula v0.20.5)
View SourceMacula Certificate Trust Store
ETS-based storage for trusted realm certificates. Manages trust decisions for self-sovereign certificates.
Trust Model: - Realm certificates are added to the trust store explicitly - Instance certificates are verified against their realm's certificate - Trust-on-first-use (TOFU) can be enabled for automatic trust
Example usage:
%% Start the trust store
{ok, Pid} = macula_trust_store:start_link(),
%% Add a trusted realm certificate
ok = macula_trust_store:add_trusted_realm(RealmDID, RealmCert),
%% Check if a realm is trusted
true = macula_trust_store:is_trusted(RealmDID),
%% Get the certificate for verification
{ok, RealmCert} = macula_trust_store:get_realm_cert(RealmDID),
%% Verify an instance certificate
ok = macula_trust_store:verify_instance_cert(InstanceCert).
Summary
Functions
Add a realm certificate to the trust store
Add a realm certificate with optional notes
Clear all trusted realms (use with caution!)
Get the count of trusted realms
Get the certificate for a trusted realm
Check if a realm DID is in the trust store
List all trusted realm DIDs
Remove a realm from the trust store
Start the trust store with default options
Start the trust store with custom options
Verify an instance certificate against the trust store Looks up the issuer's realm certificate and verifies the chain.
Types
-type macula_cert() :: #macula_cert{subject_did :: binary(), subject_cn :: binary(), issuer_did :: binary(), issuer_cn :: binary(), not_before :: non_neg_integer(), not_after :: non_neg_integer(), public_key :: binary(), signature :: binary(), serial :: binary(), version :: pos_integer(), extensions :: map()}.
Functions
-spec add_trusted_realm(RealmDID :: binary(), Cert :: macula_cert()) -> ok | {error, term()}.
Add a realm certificate to the trust store
-spec add_trusted_realm(RealmDID :: binary(), Cert :: macula_cert(), Notes :: binary()) -> ok | {error, term()}.
Add a realm certificate with optional notes
-spec clear_all() -> ok.
Clear all trusted realms (use with caution!)
-spec count() -> non_neg_integer().
Get the count of trusted realms
-spec get_realm_cert(RealmDID :: binary()) -> {ok, macula_cert()} | {error, not_found}.
Get the certificate for a trusted realm
Check if a realm DID is in the trust store
-spec list_trusted() -> [binary()].
List all trusted realm DIDs
-spec remove_trusted_realm(RealmDID :: binary()) -> ok | {error, not_found}.
Remove a realm from the trust store
Start the trust store with default options
Start the trust store with custom options
-spec verify_instance_cert(Cert :: macula_cert()) -> ok | {error, term()}.
Verify an instance certificate against the trust store Looks up the issuer's realm certificate and verifies the chain.