Skip to main content

read_secret_file

Function read_secret_file 

Source
pub fn read_secret_file(
    path: &Path,
    max_bytes: usize,
) -> Result<String, SecretInputError>
Expand description

Read UTF-8 secret material from a file, or standard input when path is -.

The limit includes the optional final line ending. Exactly one final LF, optionally preceded by CR, is removed; all other whitespace is preserved. Errors deliberately omit paths, contents, and underlying error messages.

Callers must check all input sources for conflicts before reading, including ensure_single_stdin. Noninteractive daemons must reject - themselves. Parsing the returned value must not expose its contents in diagnostics.