1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use ;
use crateTransportError;
use crateServerConfigSource;
/// Implemented by each transport's `ServerConfig` to fill in any key material it's still missing,
/// generating fresh material via `rng`.
///
/// Every other field (listen address, connection limits, transport-specific knobs like SSH's
/// `expected_username`) is set the ordinary way -- `Self::default()`, optionally with a
/// struct-update override -- before calling this; there's no separate params type, since each
/// `ServerConfig` already carries exactly the fields generation needs to inspect (a key field
/// already `Some` means "reuse this", `None` means "generate one").
///
/// Generation never touches the filesystem and can't fail: any key material it invents is
/// embedded directly in the returned config (e.g. as a base64 `identity_key`). Moving that inline
/// material out to a file on disk is a distinct, separate, fallible step -- see
/// [`ExternalizeKeyMaterial`].
///
/// Implemented internally within `nym-bridges` for each transport (see the `quic`, `tls`, and
/// `ssh` modules); external tooling (e.g. `bridge-cfg`) drives generation generically rather than
/// special-casing each transport type.
/// Key material [`ExternalizeKeyMaterial::externalize_keys`] moved out of a config, for the
/// caller to actually write to disk.
/// Implemented by each transport's `ServerConfig` to move any inline (base64) key material it
/// carries out to PEM file(s) on disk -- for operators who want key material kept out of the
/// config file itself, e.g. to apply stricter file permissions to it independently.
///
/// Complements [`GenerateServerConfig`]: generation only ever produces in-memory/inline key
/// material and so needs no `Path` and can't fail; externalizing that material to files is a
/// distinct, later, fallible (re-parsing the inline key to re-encode it as PEM) step, and entirely
/// optional -- a config with inline key material is already complete and usable as-is.
/// Shared by every transport's [`ExternalizeKeyMaterial`] impl: move `identity_key` (if set) out
/// to a PEM file named `default_filename` under `dir`. No-op if `identity_key` is already unset
/// (there's no identity yet, or it's already file-backed).