Silk

silk/native_file_trust_source

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, x86_64-unknown-linux-gnu.

Explicit bounded PEM-file trust for selected native libc targets.

When to use

Construct NativeFileTrustSource at a native application edge when the application has selected one regular PEM bundle file. Provide it lexically as silk.trust_source.TrustSource.

Details

Construction copies an absolute native root and an existing normalized portable Path without performing I/O. Each load opens the file anew, reads no more than the caller's input budget, closes it, then decodes the complete bytes through TrustSnapshot.fromPem. Returned snapshots own their anchors independently of this provider and every later load.

The configured root and its ancestors are trusted application configuration. The root itself and every component beneath it use NativeFileSystem's descriptor-relative no-follow traversal. Publish replacement files by atomic rename when one consistent file generation is required; in-place modification has no point-in-time snapshot guarantee.

Gotchas

This actor does not select defaults, search directories, inspect environment variables, invoke platform trust APIs, or reproduce OS trust settings, revocation, or purpose policy. It is absent on WebAssembly and native no-libc profiles.

Examples

Configure explicit regular PEM files without reading them

Debian applications can explicitly select the generated regular bundle without scanning its sibling certificate links. Darwin applications must first export their chosen authorities to a caller-managed regular PEM file; this actor does not read the system keychain. Both constructors below only validate and copy configuration, so the example is executable on either supported platform without opening either file.

import silk.allocator as Allocators {Allocator, OutOfMemoryError}
import silk.effect as Effects {Effect}
import silk.filesystem as FileSystems {FileError, Path}
import silk.native_file_trust_source as NativeTrust {NativeFileTrustSource}
import silk.trust_snapshot as TrustSnapshots {TrustSourceError}

effect fn program() -> i32 ! FileError | TrustSourceError | OutOfMemoryError {
  let mut allocator = Allocator.systemAllocatorProvider()
  let debianPath = run Path.fromBytes(b"/ca-certificates.crt")
    |> Effect.provideMut<Allocator>(&mut allocator)
  let debian = run NativeFileTrustSource.make(b"/etc/ssl/certs", &debianPath)
    |> Effect.provideMut<Allocator>(&mut allocator)
  let darwinPath = run Path.fromBytes(b"/trust.pem")
    |> Effect.provideMut<Allocator>(&mut allocator)
  let darwin = run NativeFileTrustSource.make(
    b"/Library/Application Support/Example",
    &darwinPath,
  )
    |> Effect.provideMut<Allocator>(&mut allocator)
  drop debian
  drop darwin
  return 42
}

effect fn recover(error: FileError | TrustSourceError | OutOfMemoryError) -> i32 {
  return 0
}

pub fn main() -> i32 {
  let result = run Effect.catchAll(program(), recover)
  if result != 42 {
    let mismatch = 1 / 0
  }
  return 0
}

Import as NativeFileTrustSource with import silk.native_file_trust_source { NativeFileTrustSource }.

Public declarations: 1.

NativeFileTrustSource

pub struct NativeFileTrustSource

A mutable native provider that owns one explicit root and portable PEM-file path.

Details

The provider contains configuration only. It opens the configured path for every load and never caches, installs, or replaces caller-owned snapshots.

Associated function NativeFileTrustSource.make

pub effect<'env> fn make<'life0: 'env, 'life1: 'env, 'env>(root: &'life0 [u8], path: &'life1 silk/filesystem.Path) -> NativeFileTrustSource ! TrustSourceError | OutOfMemoryError ? &mut Allocator

Validates and copies explicit native file-trust configuration without performing I/O.

Details

root must be nonempty, absolute, and NUL-free. The combined root and normalized portable path length must not exceed 4096 bytes. Each accepted input is copied into independent storage. Invalid configuration fails with TrustSourceError; caller allocation refusal remains OutOfMemoryError.

Implementation TrustSource for NativeFileTrustSource

impl TrustSource for NativeFileTrustSource

Operation load

load = NativeFileTrustSource.loadCurrent

On this page