package core:crypto/cert_store
Overview
Trusted root certificates for verifying TLS servers.
A handshake trusts either the operating system or a caller's Store, never both:
- nil: the operating system decides. Windows uses CryptoAPI and macOS the Security framework, both with their own policy, which may be stricter than RFC 5280 and may fetch missing intermediates. Linux, the BSDs and Android load the system roots once, on first use; SSL_CERT_FILE and SSL_CERT_DIR override where they are read from. Other targets trust nothing.
- A Store: only its roots are trusted, for example a development CA. To trust a development CA as well as the public roots, load both into one Store.
A Store is not synchronized: fill it before sharing it between threads.
Example:
store: cert_store.Store
cert_store.init(&store)
defer cert_store.destroy(&store)
if err := cert_store.append_pem(&store, DEV_CA_PEM); err != nil {
return err
}
err := tls.client_handshake(&socket, tcp, "dev.example.test", &store)
Index
Constants (0)
This section is empty.
Variables (0)
This section is empty.
Procedures (5)
Procedure Groups (0)
This section is empty.
Types
Error ¶
Error :: union { runtime.Allocator_Error, pem.Decode_Error, x509.Error, }
Related Procedures With Returns
Store ¶
Store :: struct { roots: [dynamic]^x509.Certificate, seen: map[string]struct {}, }
Related Procedures With Parameters
Constants
This section is empty.
Variables
This section is empty.
Procedures
append_der ¶
append_der adds a DER-encoded certificate as a trusted root. The bytes are copied. A certificate already in the store is ignored, and on error the store is unchanged.
append_pem ¶
append_pem adds every CERTIFICATE block in data as a trusted root,
in order, skipping other blocks and the text between them. It stops
at the first block that fails to decode or parse; the roots added
before it stay in the store.
destroy ¶
destroy :: proc(store: ^Store) {…}
destroy frees every certificate in the store and resets it.
init ¶
init :: proc(store: ^Store, allocator := context.allocator) {…}
init prepares an empty store that allocates with allocator.
verify ¶
@(require_results) verify :: proc( store: ^Store, leaf: ^x509.Certificate, intermediates: []^x509.Certificate, host_name: string, now: time.Time, allocator := context.allocator, ) -> x509.Error {…}
verify checks that leaf, with the peer's intermediates, chains to
a trusted root and is valid for TLS server authentication at now.
A non-empty host_name must match the leaf.
A nil store uses the operating system's roots and policy; otherwise
only the store's roots are trusted. allocator is used for
temporaries only.
Procedure Groups
This section is empty.
Source Files
- cert_store.odin
- common.odin
- doc.odin
- (hidden platform specific files)
Generation Information
Generated with odin version dev-2026-11 (vendor "odin") Windows_amd64 @ 2026-11-30 21:05:49.814964300 +0000 UTC