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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
//! Various Krill-wide constants.
use CaHandle;
use crateNamespace;
use crateActor;
//------------ Binary Names -------------------------------------------------
/// The friendly name of the `krill` binary.
pub const KRILL_SERVER_APP: &str = "Krill";
/// The friendly name of the `krillup` binary.
pub const KRILL_UP_APP: &str = "Krill Upgrade Helper";
/// The friendly name of the `krillc` binary.
pub const KRILL_CLIENT_APP: &str = "Krill Client";
/// The friendly name of the `krillta` binary.
pub const KRILL_TA_CLIENT_APP: &str = "Krill Trust Anchor Client";
//------------ Config Files Paths -------------------------------------------
/// The default path to the Krill config file.
pub const KRILL_DEFAULT_CONFIG_FILE: &str = "/etc/krill.conf";
/// The default path to the `krillta` config file.
pub const KRILL_DEFAULT_TA_CONFIG_FILE: &str = "/etc/krillta.conf";
//------------ Environment Variables ----------------------------------------
/// The environment variable signalling test mode.
///
/// Test mode is enabled when this variable is set to any value.
const KRILL_ENV_TEST: &str = "KRILL_TEST";
/// The environment variable signalling test announcements.
///
/// Test announcements are enabled if this variable is set to any value.
const KRILL_ENV_TEST_ANN: &str = "KRILL_TEST_ANN";
/// The environment variable signalling to only upgrade data.
///
/// If this variable is set, the Krill server will exit after upgrading the
/// data.
pub const KRILL_ENV_UPGRADE_ONLY: &str = "KRILL_UPGRADE_ONLY";
/// The environment variable with the log level.
///
/// The variable should contain the name of a [`log::LevelFilter`]. It will
/// be overwritten by the config file. The default is “info.”
pub const KRILL_ENV_LOG_LEVEL: &str = "KRILL_LOG_LEVEL";
/// The environment variable with the log target.
///
/// The variable should contain the name of a
/// [`LogType`][crate::daemon::config::LogType]. It will be overwritten by
/// the config file. The default is “file.”
pub const KRILL_ENV_LOG_TYPE: &str = "KRILL_LOG_TYPE";
/// The environment variable with the Krill admin token.
///
/// This is primarily used to safely signal the admin token to `krillc`.
pub const KRILL_ENV_ADMIN_TOKEN: &str = "KRILL_ADMIN_TOKEN";
/// The deprecated environment variable with the Krill admin token.
///
/// The name in [`KRILL_ENV_ADMIN_TOKEN`] should be used instead.
pub const KRILL_ENV_ADMIN_TOKEN_DEPRECATED: &str = "KRILL_AUTH_TOKEN";
/// The environment variable indicating to log HTTP requests.
///
/// If this variable is set, the HTTP server will log all requests at log
/// level “info.”
pub const KRILL_ENV_HTTP_LOG_INFO: &str = "KRILL_HTTP_LOG_INFO";
/// The environment variable indicating the default storage URI.
///
/// The value will be overwritten with that in the config file. Defaults to
/// `local://./data` if not set or not a valid URI.
pub const KRILL_ENV_STORAGE_URI: &str = "KRILL_STORAGE_URI";
/// The environment variable directing `krill` to print the request and exit.
///
/// If this variable is set, `krillc` will not execute the requested function
/// but just print out the HTTP request it would need to perform and exit.
pub const KRILL_CLI_API_ENV: &str = "KRILL_CLI_API";
/// The environment variable with the path to HTTPS root certificates.
///
/// This is used when Krill needs to make HTTP requests.
pub const KRILL_HTTPS_ROOT_CERTS_ENV: &str = "KRILL_HTTPS_ROOT_CERTS";
// XXX The following functions should probably live somewhere else. But
// where?
//
// The use of environment variables here is very unsafe and we should
// probably replace this with something else.
/// Sets the environment variable to enable test mode.
/// Returns whether the environment variable to enable test mode is set.
/// Sets the environment variable to enable test announcements.
/// Returns whether the environment variable for test announcements is set.
//------------ Storage Namespaces -------------------------------------------
/// The namespace for the CA manager.
///
pub const CASERVER_NS: &Namespace = make;
/// The namespace for CA objects store.
pub const CA_OBJECTS_NS: &Namespace = make;
/// The namespace for the keys of the signer.
pub const KEYS_NS: &Namespace = make;
/// The namespace for the property manager.
pub const PROPERTIES_NS: &Namespace = make;
/// The namespace for the publication server content.
pub const PUBSERVER_CONTENT_NS: &Namespace = make;
/// The namespace for the publication server.
pub const PUBSERVER_NS: &Namespace = make;
/// The namespace for the signer.
pub const SIGNERS_NS: &Namespace = make;
/// The namespace for the status manager.
pub const STATUS_NS: &Namespace = make;
/// The namespace for the trust anchor proxy.
pub const TA_PROXY_SERVER_NS: &Namespace = make;
/// The namespace for the trust anchor signer.
pub const TA_SIGNER_SERVER_NS: &Namespace = make;
/// The namespace for the task queue.
pub const TASK_QUEUE_NS: &Namespace = make;
//------------ Property Manager Defaults ------------------------------------
/// The name of the single instance stored by the property manager.
pub const PROPERTIES_DFLT_NAME: &str = "main";
//------------ Publication Server Defaults ----------------------------------
/// The name of the single instance used by the publication server.
///
/// This is will be the scope of the object in the [`PUBSERVER_NS`]
/// namespace.
pub const PUBSERVER_DFLT: &str = "0";
//------------ Repository Defaults ------------------------------------------
/// The default sub-directory for the repository.
///
/// This is used if `repo_dir` is not given explicitly in the config file and
/// is appended to the data directory.
pub const REPOSITORY_DIR: &str = "repo";
/// The name of the subdirectory for RRDP data.
pub const REPOSITORY_RRDP_DIR: &str = "rrdp";
/// The name of the subdirectory for RRDP archive data.
pub const REPOSITORY_RRDP_ARCHIVE_DIR: &str = "archive";
/// The first RRDP serial number.
///
/// RFC 8182 says we MUST use 1 as the first serial.
pub const RRDP_FIRST_SERIAL: u64 = 1;
/// The name of the subdirectory for rsync data.
pub const REPOSITORY_RSYNC_DIR: &str = "rsync";
//------------ CA Manager Defaults -------------------------------------------
/// The minimum value for the `ca_refresh_seconds` config value.
pub const CA_REFRESH_SECONDS_MIN: u32 = 3600;
/// The maximum value for the `ca_refresh_seconds` config value.
pub const CA_REFRESH_SECONDS_MAX: u32 = 3 * 24 * 3600; // 3 days
/// The minimum value of `suspend_child_after_inactive_hours` config value.
pub const CA_SUSPEND_MIN_HOURS: u32 = 48; // 2 days
//------------ Scheduler Defaults --------------------------------------------
/// The delay before retrying a failed remote command.
pub const SCHEDULER_REQUEUE_DELAY_SECONDS: i64 = 300;
/// The number of CAs configured that stop Krill from resyncing repo at start.
pub const SCHEDULER_RESYNC_REPO_CAS_THRESHOLD: usize = 5;
/// The number of CAs configured before jitter is used when syncing at start.
pub const SCHEDULER_USE_JITTER_CAS_THRESHOLD: usize = 50;
/// The interval between re-publishing MFT/CRL if needed.
pub const SCHEDULER_INTERVAL_REPUBLISH_MINS: i64 = 5;
/// The interval between renewing objects if needed.
pub const SCHEDULER_INTERVAL_RENEW_MINS: i64 = 60;
//------------ HTTP Client Defaults ------------------------------------------
/// The HTTP client request timeout.
pub const HTTP_CLIENT_TIMEOUT_SECS: u64 = 120;
/// The maximum length of a user agent string taken from HTTP requests.
///
/// If the user agent value in an incoming request is longer than this value,
/// it will be truncated before being stored or otherwise processed.
pub const HTTP_USER_AGENT_TRUNCATE: usize = 256;
/// The HTTP client request timeout used by the OpenID Connect auth provider.
pub const OPENID_CONNECT_HTTP_CLIENT_TIMEOUT_SECS: u64 = 30;
//------------ Built-in Actors -----------------------------------------------
/// The actor used by the Krill server.
pub const ACTOR_DEF_KRILL: Actor = system;
/// The actor used by the Krill TA.
pub const ACTOR_DEF_KRILLTA: Actor = system;
/// The anonymous actor.
pub const ACTOR_DEF_ANON: Actor = anonymous;
/// The actor represented by the admin token.
pub const ACTOR_DEF_ADMIN_TOKEN: Actor = system;
/// The actor used by the Krill test bed.
pub const ACTOR_DEF_TESTBED: Actor = system;
/// The actor used by tests.
pub const ACTOR_DEF_TEST: Actor = system;
//------------ Trust Anchor --------------------------------------------------
/// The name of the handle to be used for the TA.
pub const TA_NAME: &str = "ta";
/// Returns a CA handle for the trust anchor CA.
/// The resource class name to be used by the trust anchor.
//------------ Testbed -------------------------------------------------------
/// The handle of the CA used by the testbed.
pub const TESTBED_CA_NAME: &str = "testbed";
/// Returns the CA handle for the testbed.
//------------ Config File Auth Provider Defaults ----------------------------
//
// Note: These must match the values used by Lagosta.
/// The log₂ of the Scrypt parameter `N` used by the UI to submit a password.
pub const PW_HASH_LOG_N: u8 = 13;
/// The Scrypt parameter `r` used by the UI to submit a password.
pub const PW_HASH_R: u32 = 8;
/// The Scrypt parameter `p` used by the UI to submit a password.
pub const PW_HASH_P: u32 = 1;
//------------ Signer Defaults -----------------------------------------------
/// The validity of a newly created ID certificate.
pub const ID_CERTIFICATE_VALIDITY_YEARS: i32 = 15;
/// The name of the default signer.
pub const DEFAULT_SIGNER_NAME: &str = "Default OpenSSL signer";
/// The name of the default signer.
pub const DEFAULT_SIGNER_NAME: &str = "Default OpenSSL signer";
/// The name of the default signer.
pub const DEFAULT_SIGNER_NAME: &str = "(test mode) Default KMIP signer";
/// The name of the default signer.
pub const DEFAULT_SIGNER_NAME: &str = "(test mode) Default PKCS#11 signer";
/// The name of the one-off signer.
pub const OPENSSL_ONE_OFF_SIGNER_NAME: &str = "OpenSSL one-off signer";