@@ -496,10 +496,68 @@ fn prepare_server_config_with_drivers(
496496 None => defaults:: complete_local_jwt_config ( ) ?,
497497 } ;
498498
499+ let config = assemble_server_config ( args, matches, file. as_ref ( ) , gateway_jwt) ?;
500+
501+ if let Some ( normalized) = normalized_network_trust. as_ref ( ) {
502+ // Use the same resolver as runtime construction, with the explicit
503+ // configuration marker but no synthetic/staged artifact. This rejects
504+ // remote endpoints and factories that have not opted into trust
505+ // propagation before any state is written.
506+ let driver_startup = crate :: compute:: driver_config:: DriverStartupContext {
507+ file : file. as_ref ( ) ,
508+ guest_tls : guest_tls. as_ref ( ) ,
509+ network_trust : None ,
510+ network_trust_configured : true ,
511+ gateway_port : config. bind_address . port ( ) ,
512+ gateway_tls_enabled : config. tls . is_some ( ) ,
513+ endpoint_overrides : & config. compute_driver_endpoints ,
514+ } ;
515+ crate :: validate_compute_driver_config (
516+ compute_drivers,
517+ compute_driver. name ( ) ,
518+ & config. name ,
519+ config. bind_address ,
520+ & config. log_level ,
521+ driver_startup,
522+ false ,
523+ )
524+ . map_err ( |error| {
525+ miette:: miette!(
526+ "Network supervisor additional destination trust configured: certificate_count={} digest={}: {error}" ,
527+ normalized. certificate_count( ) ,
528+ normalized. digest( )
529+ )
530+ } ) ?;
531+ }
532+ let network_trust = normalized_network_trust
533+ . map ( crate :: network_trust:: stage_normalized)
534+ . transpose ( ) ?;
535+
536+ Ok ( ServerStartupConfig {
537+ config,
538+ config_file : file,
539+ guest_tls,
540+ network_trust,
541+ compute_driver,
542+ legacy_compute_driver_env_seen,
543+ } )
544+ }
545+
546+ /// Build the gateway's runtime configuration from the effective arguments and
547+ /// the configuration file. This has no side effects beyond reading
548+ /// `OPENSHELL_PROVISIONING_REPAIR_WINDOW_SECONDS`: it creates no directories,
549+ /// stages no artifacts and probes no drivers, so a failure here is a pure
550+ /// configuration error.
551+ fn assemble_server_config (
552+ args : & RunArgs ,
553+ matches : & ArgMatches ,
554+ file : Option < & ConfigFile > ,
555+ gateway_jwt : Option < openshell_core:: GatewayJwtConfig > ,
556+ ) -> Result < openshell_core:: Config > {
499557 let bind = SocketAddr :: new ( args. bind_address , args. port ) ;
500558
501559 let has_client_ca = args. tls_client_ca . is_some ( ) ;
502- let mtls_auth_enabled = resolve_mtls_auth_enabled ( args, matches, file. as_ref ( ) ) ;
560+ let mtls_auth_enabled = resolve_mtls_auth_enabled ( args, matches, file) ;
503561
504562 if args. disable_tls && has_client_ca {
505563 return Err ( miette:: miette!(
@@ -846,49 +904,7 @@ fn prepare_server_config_with_drivers(
846904 // Reject invalid broker before startup; gateway state parses it later.
847905 crate :: spiffe_broker:: validate_config ( & config) . map_err ( |error| miette:: miette!( "{error}" ) ) ?;
848906
849- if let Some ( normalized) = normalized_network_trust. as_ref ( ) {
850- // Use the same resolver as runtime construction, with the explicit
851- // configuration marker but no synthetic/staged artifact. This rejects
852- // remote endpoints and factories that have not opted into trust
853- // propagation before any state is written.
854- let driver_startup = crate :: compute:: driver_config:: DriverStartupContext {
855- file : file. as_ref ( ) ,
856- guest_tls : guest_tls. as_ref ( ) ,
857- network_trust : None ,
858- network_trust_configured : true ,
859- gateway_port : config. bind_address . port ( ) ,
860- gateway_tls_enabled : config. tls . is_some ( ) ,
861- endpoint_overrides : & config. compute_driver_endpoints ,
862- } ;
863- crate :: validate_compute_driver_config (
864- compute_drivers,
865- compute_driver. name ( ) ,
866- & config. name ,
867- config. bind_address ,
868- & config. log_level ,
869- driver_startup,
870- false ,
871- )
872- . map_err ( |error| {
873- miette:: miette!(
874- "Network supervisor additional destination trust configured: certificate_count={} digest={}: {error}" ,
875- normalized. certificate_count( ) ,
876- normalized. digest( )
877- )
878- } ) ?;
879- }
880- let network_trust = normalized_network_trust
881- . map ( crate :: network_trust:: stage_normalized)
882- . transpose ( ) ?;
883-
884- Ok ( ServerStartupConfig {
885- config,
886- config_file : file,
887- guest_tls,
888- network_trust,
889- compute_driver,
890- legacy_compute_driver_env_seen,
891- } )
907+ Ok ( config)
892908}
893909
894910const UNAUTHENTICATED_USERS_WARNING : & str = "unauthenticated user access is enabled; only use this for trusted local development or a fully trusted fronting proxy" ;
0 commit comments