Skip to main content

rustls_extra_roots/
lib.rs

1//! The built-in Mozilla roots, plus a corporate CA bundle the environment
2//! names.
3//!
4//! A program that makes outbound TLS connections from inside a corporate
5//! network usually needs two things trusted at once: the public certificate
6//! authorities, and whichever internal CA the network's inspecting proxy
7//! presents. This crate is the twenty lines that combine them, plus the
8//! three rules that turn out to matter.
9//!
10//! # Three rules worth knowing first
11//!
12//! **The bundle is additional, not a replacement.** The variable is spelled
13//! `SSL_CERT_FILE` by default, and OpenSSL gives that name the opposite
14//! meaning: setting it there *replaces* the default trust store. Here it
15//! **adds** to it, because a corporate CA is issued alongside the public
16//! ones rather than instead of them. If that is not the meaning you want,
17//! name a different variable — see [`ExtraRoots::from_variable`] — but be
18//! deliberate about it. A deployment that set `SSL_CERT_FILE` expecting
19//! OpenSSL's meaning gets a *larger* trust set than it intended, never a
20//! smaller one: the safe direction to be wrong in, but still worth knowing.
21//!
22//! **A configured bundle that cannot be used is fatal.** Not a warning.
23//! Silently falling back to the default roots is how a certificate problem
24//! becomes a TLS handshake failure three hops away, in a different service,
25//! hours later. If the operator said to load a file, and the file cannot be
26//! loaded, [`validate_at_startup`] says so and the process should not
27//! start. Every error names the file, because "invalid certificate" with no
28//! path is the least useful message a deployment can fail with.
29//!
30//! **Blank is absent.** `SSL_CERT_FILE=""` means the variable was not set.
31//! A templated container definition whose source was empty produces exactly
32//! that, and reading it as "load the file named empty string" fails a
33//! service for a reason nobody can see in the definition.
34//!
35//! # Why not something that already exists
36//!
37//! [`webpki-roots`] compiles the Mozilla set in and offers no way to extend
38//! it. [`rustls-native-certs`] reads the operating system's store, which is
39//! a different thing: it replaces the Mozilla set with the host's, and in a
40//! distroless or scratch container there is no host store to read.
41//! `webpki-roots-patcher` solves the same problem with `LD_PRELOAD`. What
42//! is missing is the boring middle: compiled-in roots, plus one file, from
43//! inside the process.
44//!
45//! [`webpki-roots`]: https://crates.io/crates/webpki-roots
46//! [`rustls-native-certs`]: https://crates.io/crates/rustls-native-certs
47//!
48//! # Examples
49//!
50//! The usual call. With no bundle configured this is the Mozilla root set:
51//!
52//! ```
53//! let roots = rustls_extra_roots::root_store().expect("no bundle is configured here");
54//! assert!(!roots.is_empty());
55//! ```
56//!
57//! Checking a specific file, which is what the startup check does:
58//!
59//! ```
60//! use std::path::Path;
61//!
62//! let error = rustls_extra_roots::root_store_from(Some(Path::new("/nonexistent.pem")))
63//!     .expect_err("the file is not there");
64//!
65//! assert!(error.to_string().contains("/nonexistent.pem"));
66//! ```
67//!
68//! Under a different variable name, for a program that already means
69//! something else by `SSL_CERT_FILE`:
70//!
71//! ```
72//! use rustls_extra_roots::ExtraRoots;
73//!
74//! let roots = ExtraRoots::from_variable("CORPORATE_CA_BUNDLE")
75//!     .root_store()
76//!     .expect("nothing is configured under that name here");
77//! # let _ = roots;
78//! ```
79//!
80//! # Crypto providers
81//!
82//! [`root_store`] and friends need no crypto provider: assembling a trust
83//! store is not a cryptographic operation. [`client_config`] does, because
84//! `rustls` reads the process-default provider to pick cipher suites — this
85//! crate deliberately selects none, so either install one
86//! (`CryptoProvider::install_default`, or enable `ring` / `aws-lc-rs` on
87//! your own `rustls` dependency) or call
88//! [`client_config_with_provider`] to be explicit.
89
90#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used))]
91
92use std::borrow::Cow;
93use std::io;
94use std::path::{Path, PathBuf};
95use std::sync::Arc;
96
97use rustls::crypto::CryptoProvider;
98use rustls::{ClientConfig, RootCertStore};
99use rustls_pki_types::CertificateDer;
100use rustls_pki_types::pem::PemObject;
101
102/// The environment variable consulted when no other name is given.
103///
104/// See the crate documentation for why this name does not carry its
105/// OpenSSL meaning here.
106pub const DEFAULT_VARIABLE: &str = "SSL_CERT_FILE";
107
108/// Why the trust roots could not be assembled.
109///
110/// Each variant names the file. A deployment failing with "invalid
111/// certificate" and no path is a deployment somebody has to guess about.
112#[derive(Debug, thiserror::Error)]
113pub enum TrustError {
114    /// The file could not be opened, read, or parsed as PEM.
115    #[error("could not read the CA bundle {path}: {source}")]
116    Unreadable {
117        /// Which file.
118        path: String,
119        /// Why.
120        #[source]
121        source: io::Error,
122    },
123
124    /// The file was read but held no certificate.
125    ///
126    /// A PEM file of only a private key lands here, as does an empty file
127    /// and a file of PEM-looking text that parsed to nothing. All three
128    /// mean the same thing to a caller: the bundle contributed no roots, so
129    /// continuing would silently use the defaults.
130    #[error("the CA bundle {path} contains no certificate")]
131    Empty {
132        /// Which file.
133        path: String,
134    },
135
136    /// Certificates parsed, but `rustls` rejected every one of them.
137    #[error("the CA bundle {path} contains {count} certificate(s), none usable as a root")]
138    NoneUsable {
139        /// Which file.
140        path: String,
141        /// How many were read before being rejected.
142        count: usize,
143    },
144}
145
146/// Which environment variable names the bundle.
147///
148/// Construct one of these when [`DEFAULT_VARIABLE`] is not the name you
149/// want; the free functions in this crate are the same operations against
150/// the default.
151///
152/// # Examples
153///
154/// ```
155/// use rustls_extra_roots::{DEFAULT_VARIABLE, ExtraRoots};
156///
157/// assert_eq!(ExtraRoots::new().variable(), DEFAULT_VARIABLE);
158/// assert_eq!(ExtraRoots::from_variable("MY_CA_BUNDLE").variable(), "MY_CA_BUNDLE");
159/// ```
160#[derive(Debug, Clone, PartialEq, Eq)]
161pub struct ExtraRoots {
162    /// The variable to read.
163    variable: Cow<'static, str>,
164}
165
166impl Default for ExtraRoots {
167    fn default() -> Self {
168        Self::new()
169    }
170}
171
172impl ExtraRoots {
173    /// Read [`DEFAULT_VARIABLE`].
174    #[must_use]
175    pub const fn new() -> Self {
176        Self {
177            variable: Cow::Borrowed(DEFAULT_VARIABLE),
178        }
179    }
180
181    /// Read the named variable instead.
182    #[must_use]
183    pub fn from_variable(variable: impl Into<Cow<'static, str>>) -> Self {
184        Self {
185            variable: variable.into(),
186        }
187    }
188
189    /// Which variable this reads.
190    #[must_use]
191    pub fn variable(&self) -> &str {
192        &self.variable
193    }
194
195    /// The bundle this names, if it names one.
196    ///
197    /// [`None`] when unset, empty, or whitespace — blank is absent.
198    #[must_use]
199    pub fn configured_bundle(&self) -> Option<PathBuf> {
200        bundle_from_value(std::env::var(self.variable.as_ref()).ok().as_deref())
201    }
202
203    /// Trust roots: the built-in set, plus whatever this variable names.
204    ///
205    /// # Errors
206    ///
207    /// [`TrustError`] if a bundle is configured and cannot be used. No
208    /// error is possible when none is configured.
209    pub fn root_store(&self) -> Result<RootCertStore, TrustError> {
210        root_store_from(self.configured_bundle().as_deref())
211    }
212
213    /// A client configuration trusting [`ExtraRoots::root_store`], with no
214    /// client certificate.
215    ///
216    /// # Panics
217    ///
218    /// Through `rustls`, if no process-default [`CryptoProvider`] has been
219    /// installed. See the crate documentation, or use
220    /// [`client_config_with_provider`].
221    ///
222    /// # Errors
223    ///
224    /// [`TrustError`], as [`ExtraRoots::root_store`].
225    pub fn client_config(&self) -> Result<ClientConfig, TrustError> {
226        Ok(ClientConfig::builder()
227            .with_root_certificates(self.root_store()?)
228            .with_no_client_auth())
229    }
230
231    /// Fail now if a configured bundle is unusable.
232    ///
233    /// Call this during startup, before binding a port or accepting work:
234    /// the point is that the process refuses to reach a state where it
235    /// looks healthy while being unable to make the TLS connections its
236    /// work depends on.
237    ///
238    /// Returns the bundle that was validated, so the caller can log it.
239    ///
240    /// # Errors
241    ///
242    /// [`TrustError`] if a bundle is configured and cannot be used.
243    pub fn validate(&self) -> Result<Option<PathBuf>, TrustError> {
244        let bundle = self.configured_bundle();
245        root_store_from(bundle.as_deref())?;
246        Ok(bundle)
247    }
248
249    /// The startup check, logged, as a single call a `main` can branch on.
250    ///
251    /// Returns `false` when the process must not start.
252    ///
253    /// Worth calling even from a program that does not obviously speak TLS,
254    /// if the variable is set across a whole deployment: a service that
255    /// ignored a broken value would be the one that quietly kept running
256    /// while its neighbours refused to, which is the least useful possible
257    /// arrangement.
258    ///
259    /// Call it after logging is configured, so the failure is recorded
260    /// rather than lost.
261    #[must_use]
262    pub fn startup_check(&self) -> bool {
263        match self.validate() {
264            Ok(Some(bundle)) => {
265                log_trusted(&bundle);
266                true
267            }
268            Ok(None) => true,
269            Err(error) => {
270                log_unusable(&self.variable, &error);
271                false
272            }
273        }
274    }
275}
276
277/// The blank-is-absent rule, separated from the environment that carries it.
278///
279/// Reading the variable is not the interesting part; deciding what counts
280/// as "set" is. Keeping the decision pure means a test can state the rule
281/// directly instead of mutating process-global state — which
282/// [`std::env::set_var`] is `unsafe` for good reason, and which this crate
283/// forbids outright.
284///
285/// # Examples
286///
287/// ```
288/// use std::path::PathBuf;
289/// use rustls_extra_roots::bundle_from_value;
290///
291/// assert_eq!(bundle_from_value(None), None);
292/// assert_eq!(bundle_from_value(Some("   ")), None);
293/// assert_eq!(bundle_from_value(Some("/ca.pem")), Some(PathBuf::from("/ca.pem")));
294/// ```
295#[must_use]
296pub fn bundle_from_value(value: Option<&str>) -> Option<PathBuf> {
297    value
298        .filter(|value| !value.trim().is_empty())
299        .map(PathBuf::from)
300}
301
302/// The bundle [`DEFAULT_VARIABLE`] names, if it names one.
303#[must_use]
304pub fn configured_bundle() -> Option<PathBuf> {
305    ExtraRoots::new().configured_bundle()
306}
307
308/// Trust roots: the built-in set, plus whatever [`DEFAULT_VARIABLE`] names.
309///
310/// # Errors
311///
312/// [`TrustError`] if a bundle is configured and cannot be used.
313pub fn root_store() -> Result<RootCertStore, TrustError> {
314    ExtraRoots::new().root_store()
315}
316
317/// Trust roots: the built-in set, plus `bundle` if given.
318///
319/// The explicit-path form, so a caller — and a test — can be specific
320/// rather than reaching through the environment.
321///
322/// # Errors
323///
324/// [`TrustError`] if `bundle` is [`Some`] and cannot be used.
325pub fn root_store_from(bundle: Option<&Path>) -> Result<RootCertStore, TrustError> {
326    let mut roots = RootCertStore {
327        roots: webpki_roots::TLS_SERVER_ROOTS.to_vec(),
328    };
329
330    let Some(path) = bundle else {
331        return Ok(roots);
332    };
333    let named = path.display().to_string();
334
335    // `rustls-pki-types` rather than the archived `rustls-pemfile`
336    // (RUSTSEC-2025-0134); its own advisory says this is the same code.
337    let certificates: Vec<CertificateDer<'static>> = CertificateDer::pem_file_iter(path)
338        .map_err(|error| TrustError::Unreadable {
339            path: named.clone(),
340            source: io::Error::other(error.to_string()),
341        })?
342        .collect::<Result<_, _>>()
343        .map_err(|error| TrustError::Unreadable {
344            path: named.clone(),
345            source: io::Error::other(error.to_string()),
346        })?;
347
348    if certificates.is_empty() {
349        return Err(TrustError::Empty { path: named });
350    }
351
352    // `add_parsable_certificates` counts rather than failing, because a
353    // corporate bundle legitimately carries certificates rustls will not
354    // take as roots. Some being ignored is normal; ALL being ignored means
355    // the file did nothing, which is the fatal case.
356    let count = certificates.len();
357    let (added, _ignored) = roots.add_parsable_certificates(certificates);
358    if added == 0 {
359        return Err(TrustError::NoneUsable { path: named, count });
360    }
361
362    log_loaded(&named, added, count - added);
363    Ok(roots)
364}
365
366/// A client configuration trusting [`root_store`], with no client
367/// certificate.
368///
369/// # Panics
370///
371/// Through `rustls`, if no process-default [`CryptoProvider`] has been
372/// installed. See the crate documentation, or use
373/// [`client_config_with_provider`].
374///
375/// # Errors
376///
377/// [`TrustError`], as [`root_store`].
378pub fn client_config() -> Result<ClientConfig, TrustError> {
379    ExtraRoots::new().client_config()
380}
381
382/// A client configuration trusting `bundle` in addition to the built-in
383/// roots, using an explicitly supplied crypto provider.
384///
385/// The no-panic path: nothing here consults the process-default provider,
386/// so this works in a library, in a test, and in a process that has not
387/// installed one.
388///
389/// # Errors
390///
391/// [`TrustError`] if `bundle` is [`Some`] and cannot be used, or
392/// [`rustls::Error`] if the provider supports none of the safe default
393/// protocol versions.
394pub fn client_config_with_provider(
395    provider: Arc<CryptoProvider>,
396    bundle: Option<&Path>,
397) -> Result<ClientConfig, ConfigError> {
398    let roots = root_store_from(bundle)?;
399    Ok(ClientConfig::builder_with_provider(provider)
400        .with_safe_default_protocol_versions()?
401        .with_root_certificates(roots)
402        .with_no_client_auth())
403}
404
405/// Why a client configuration could not be built.
406#[derive(Debug, thiserror::Error)]
407pub enum ConfigError {
408    /// The trust roots could not be assembled.
409    #[error(transparent)]
410    Trust(#[from] TrustError),
411
412    /// `rustls` would not build a configuration from the given provider.
413    #[error(transparent)]
414    Rustls(#[from] rustls::Error),
415}
416
417/// Fail now if a bundle configured under [`DEFAULT_VARIABLE`] is unusable.
418///
419/// Returns the bundle that was validated, so the caller can log it.
420///
421/// # Errors
422///
423/// [`TrustError`] if a bundle is configured and cannot be used.
424pub fn validate_at_startup() -> Result<Option<PathBuf>, TrustError> {
425    ExtraRoots::new().validate()
426}
427
428/// The startup check against [`DEFAULT_VARIABLE`], logged, as a single call
429/// a `main` can branch on.
430///
431/// Returns `false` when the process must not start.
432///
433/// # Examples
434///
435/// ```no_run
436/// use std::process::ExitCode;
437///
438/// fn main() -> ExitCode {
439///     if !rustls_extra_roots::startup_check() {
440///         return ExitCode::FAILURE;
441///     }
442///     ExitCode::SUCCESS
443/// }
444/// ```
445#[must_use]
446pub fn startup_check() -> bool {
447    ExtraRoots::new().startup_check()
448}
449
450// The three log sites, in one place so that `--no-default-features` costs
451// three empty functions rather than `cfg` noise through the logic above.
452
453#[cfg(feature = "tracing")]
454fn log_loaded(path: &str, added: usize, ignored: usize) {
455    tracing::info!(path, added, ignored, "loaded the additional CA bundle");
456}
457
458#[cfg(not(feature = "tracing"))]
459#[allow(clippy::needless_pass_by_value)]
460fn log_loaded(_path: &str, _added: usize, _ignored: usize) {}
461
462#[cfg(feature = "tracing")]
463fn log_trusted(bundle: &Path) {
464    tracing::info!(
465        bundle = %bundle.display(),
466        "trusting an additional CA bundle alongside the built-in roots"
467    );
468}
469
470#[cfg(not(feature = "tracing"))]
471fn log_trusted(_bundle: &Path) {}
472
473#[cfg(feature = "tracing")]
474fn log_unusable(variable: &str, error: &TrustError) {
475    tracing::error!(
476        %error,
477        variable,
478        "the configured CA bundle is not usable, so this process will not start"
479    );
480}
481
482#[cfg(not(feature = "tracing"))]
483fn log_unusable(_variable: &str, _error: &TrustError) {}
484
485#[cfg(test)]
486mod tests {
487    use super::*;
488
489    /// A file in the temporary directory, removed when the test ends.
490    ///
491    /// Twenty lines rather than a `tempfile` dependency: this crate exists
492    /// partly to argue against adding dependencies for one use. The name
493    /// carries the process id and a counter because `cargo test` runs these
494    /// in parallel.
495    struct TempPem(PathBuf);
496
497    impl TempPem {
498        fn new(contents: &[u8]) -> Self {
499            use std::sync::atomic::{AtomicU32, Ordering};
500            static NEXT: AtomicU32 = AtomicU32::new(0);
501
502            let path = std::env::temp_dir().join(format!(
503                "rustls-extra-roots-{}-{}.pem",
504                std::process::id(),
505                NEXT.fetch_add(1, Ordering::Relaxed)
506            ));
507            std::fs::write(&path, contents).expect("the temporary directory is writable");
508            Self(path)
509        }
510
511        fn path(&self) -> &Path {
512            &self.0
513        }
514    }
515
516    impl Drop for TempPem {
517        fn drop(&mut self) {
518            let _ = std::fs::remove_file(&self.0);
519        }
520    }
521
522    /// A real, self-signed CA certificate, so the happy path is tested
523    /// against something rustls actually accepts as a root rather than
524    /// against a string that merely looks like PEM.
525    const A_REAL_CA: &str = include_str!("../tests/a-real-ca.pem");
526
527    #[test]
528    fn no_bundle_configured_gives_the_built_in_roots() {
529        let roots = root_store_from(None).expect("no bundle cannot fail");
530        assert_eq!(
531            roots.len(),
532            webpki_roots::TLS_SERVER_ROOTS.len(),
533            "with nothing configured the store is exactly the compiled-in set"
534        );
535    }
536
537    #[test]
538    fn a_bundle_adds_to_the_built_in_roots_rather_than_replacing_them() {
539        let pem = TempPem::new(A_REAL_CA.as_bytes());
540        let roots = root_store_from(Some(pem.path())).expect("a real CA is usable");
541
542        // The rule this crate exists to state: the variable means
543        // *additional* here, unlike OpenSSL's meaning of the same name.
544        assert_eq!(
545            roots.len(),
546            webpki_roots::TLS_SERVER_ROOTS.len() + 1,
547            "the bundle's certificate is added to the compiled-in set, not \
548             substituted for it"
549        );
550    }
551
552    #[test]
553    fn a_missing_file_is_a_startup_failure_naming_the_file() {
554        let error = root_store_from(Some(Path::new("/no/such/bundle.pem")))
555            .expect_err("a configured bundle that cannot be read is fatal");
556
557        assert!(matches!(error, TrustError::Unreadable { .. }));
558        assert!(
559            error.to_string().contains("/no/such/bundle.pem"),
560            "the message must name the file: {error}"
561        );
562    }
563
564    #[test]
565    fn an_empty_file_is_a_startup_failure() {
566        let pem = TempPem::new(b"");
567        let error = root_store_from(Some(pem.path())).expect_err("no certificates means fatal");
568
569        assert!(matches!(error, TrustError::Empty { .. }), "{error}");
570    }
571
572    #[test]
573    fn a_file_of_only_a_private_key_is_a_startup_failure() {
574        // The plausible operator mistake: mounting the key beside the
575        // certificate and naming the wrong one. It is readable, it is valid
576        // PEM, and it contributes no roots — which is exactly the case this
577        // rule exists for, because the default roots would otherwise carry
578        // on working until the one connection that needed the corporate CA
579        // failed somewhere else.
580        let pem = TempPem::new(
581            b"-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIA==\n-----END PRIVATE KEY-----\n",
582        );
583        let error = root_store_from(Some(pem.path())).expect_err("a key is not a certificate");
584
585        assert!(matches!(error, TrustError::Empty { .. }), "{error}");
586    }
587
588    #[test]
589    fn text_that_is_not_pem_at_all_is_a_startup_failure() {
590        let pem = TempPem::new(b"this is not a certificate\n");
591        let error = root_store_from(Some(pem.path())).expect_err("not a bundle");
592
593        // Whether the reader calls this unreadable or empty is its own
594        // business; what matters is that it does not succeed.
595        assert!(
596            matches!(
597                error,
598                TrustError::Empty { .. } | TrustError::Unreadable { .. }
599            ),
600            "{error}"
601        );
602    }
603
604    #[test]
605    fn blank_is_absent() {
606        // A templated container definition whose source was empty produces
607        // `SSL_CERT_FILE=`, and reading that as "load the file named empty
608        // string" fails a service for a reason nobody can see in the
609        // definition.
610        for blank in [None, Some(""), Some(" "), Some("\t"), Some("   \n ")] {
611            assert!(
612                bundle_from_value(blank).is_none(),
613                "{blank:?} must read as absent"
614            );
615        }
616    }
617
618    #[test]
619    fn a_named_bundle_is_taken_as_given() {
620        assert_eq!(
621            bundle_from_value(Some("/some/bundle.pem")),
622            Some(PathBuf::from("/some/bundle.pem"))
623        );
624
625        // Surrounding whitespace decides absence but is not stripped from a
626        // real value: a path is whatever the operator wrote, and silently
627        // trimming one would be a second, invisible rule.
628        assert_eq!(
629            bundle_from_value(Some(" /padded.pem ")),
630            Some(PathBuf::from(" /padded.pem "))
631        );
632    }
633
634    #[test]
635    fn the_variable_name_is_a_parameter() {
636        assert_eq!(ExtraRoots::new().variable(), DEFAULT_VARIABLE);
637        assert_eq!(ExtraRoots::default().variable(), "SSL_CERT_FILE");
638
639        // Both an owned and a borrowed name, because the `Into<Cow>` bound
640        // is the whole point of accepting either.
641        assert_eq!(
642            ExtraRoots::from_variable("CORPORATE_CA_BUNDLE").variable(),
643            "CORPORATE_CA_BUNDLE"
644        );
645        assert_eq!(
646            ExtraRoots::from_variable(String::from("OWNED_NAME")).variable(),
647            "OWNED_NAME"
648        );
649    }
650
651    #[test]
652    fn an_unset_variable_reads_as_no_bundle() {
653        // A name nothing sets, so this asserts the absent path without
654        // touching process-global state.
655        let roots = ExtraRoots::from_variable("RUSTLS_EXTRA_ROOTS_DEFINITELY_UNSET");
656        assert_eq!(roots.configured_bundle(), None);
657        assert!(roots.startup_check(), "nothing configured is not a failure");
658    }
659
660    #[test]
661    fn an_explicit_provider_builds_a_configuration_without_a_process_default() {
662        // `client_config` reads the process-default provider and panics
663        // without one; this path takes the provider as an argument, which
664        // is what makes the crate usable from a library.
665        let pem = TempPem::new(A_REAL_CA.as_bytes());
666        let provider = Arc::new(rustls::crypto::ring::default_provider());
667
668        let config = client_config_with_provider(provider, Some(pem.path()))
669            .expect("a real CA and a real provider");
670
671        // `ClientConfig` does not expose its root store, so the store
672        // itself is asserted where it is built; what this test adds is
673        // that the explicit-provider path reaches a configuration at all,
674        // with no process default installed.
675        assert!(config.alpn_protocols.is_empty());
676    }
677
678    #[test]
679    fn an_unusable_bundle_fails_the_configuration_too() {
680        let provider = Arc::new(rustls::crypto::ring::default_provider());
681        let error = client_config_with_provider(provider, Some(Path::new("/no/such.pem")))
682            .expect_err("the file is not there");
683
684        assert!(matches!(error, ConfigError::Trust(TrustError::Unreadable { .. })));
685    }
686}