@@ -56,7 +56,8 @@ pub enum ObjectStoreKind {
5656 client_secret : Option < String > ,
5757 region_name : String ,
5858 endpoint : Option < String > ,
59- verify_ssl : Option < VerifySSL > ,
59+ #[ serde( default , deserialize_with = "deserialize_bool" ) ]
60+ allow_invalid_certificates : Option < bool > ,
6061 } ,
6162 Azure {
6263 container_url : String ,
@@ -71,30 +72,10 @@ fn deserialize_u64<'de, D: Deserializer<'de>>(deserializer: D) -> Result<Option<
7172 ) )
7273}
7374
74- // Wrapper type for boolean that deserializes from both bool and string
75- #[ derive( Clone , Copy , Debug , PartialEq ) ]
76- pub struct VerifySSL ( pub Option < bool > ) ;
77-
78- impl < ' de > Deserialize < ' de > for VerifySSL {
79- fn deserialize < D : Deserializer < ' de > > ( deserializer : D ) -> Result < Self , D :: Error > {
80- use serde:: de:: Error ;
81-
82- #[ derive( Deserialize ) ]
83- #[ serde( untagged) ]
84- enum BoolOrString {
85- Bool ( bool ) ,
86- String ( String ) ,
87- }
88-
89- match BoolOrString :: deserialize ( deserializer) ? {
90- BoolOrString :: Bool ( b) => Ok ( VerifySSL ( Some ( b) ) ) ,
91- BoolOrString :: String ( s) => match s. to_lowercase ( ) . as_str ( ) {
92- "true" | "1" | "yes" => Ok ( VerifySSL ( Some ( true ) ) ) ,
93- "false" | "0" | "no" => Ok ( VerifySSL ( Some ( false ) ) ) ,
94- _ => Err ( Error :: custom ( "expected 'true' or 'false' for boolean" ) ) ,
95- } ,
96- }
97- }
75+ fn deserialize_bool < ' de , D : Deserializer < ' de > > ( deserializer : D ) -> Result < Option < bool > , D :: Error > {
76+ Ok ( Some (
77+ String :: deserialize ( deserializer) ?. parse ( ) . expect ( "Expected a bool" ) ,
78+ ) )
9879}
9980
10081#[ derive( Clone , Deserialize , Debug ) ]
@@ -142,7 +123,7 @@ impl ObjectStoreConfig {
142123 client_secret,
143124 region_name,
144125 endpoint,
145- verify_ssl ,
126+ allow_invalid_certificates ,
146127 } => {
147128 let mut builder = AmazonS3Builder :: from_env ( )
148129 . with_region ( region_name. clone ( ) )
@@ -158,13 +139,13 @@ impl ObjectStoreConfig {
158139 // This is needed for minio compatibility
159140 builder = builder. with_endpoint ( endpoint. clone ( ) . unwrap ( ) ) . with_allow_http ( true ) ;
160141 }
161- if self . timeout . is_some ( ) || matches ! ( verify_ssl , Some ( VerifySSL ( Some ( false ) ) ) ) {
142+ if self . timeout . is_some ( ) || allow_invalid_certificates . is_some ( ) {
162143 let mut options = ClientOptions :: new ( ) ;
163144 if let Some ( t) = self . timeout {
164145 options = options. with_timeout ( Duration :: from_secs ( t) ) ;
165146 }
166- if let Some ( VerifySSL ( Some ( verify ) ) ) = verify_ssl {
167- options = options. with_allow_invalid_certificates ( !verify ) ;
147+ if let Some ( allow_invalid_certificates ) = allow_invalid_certificates {
148+ options = options. with_allow_invalid_certificates ( * allow_invalid_certificates ) ;
168149 }
169150 builder = builder. with_client_options ( options) ;
170151 }
@@ -481,7 +462,7 @@ mod tests {
481462 }
482463
483464 #[ test]
484- fn test_s3_verify_ssl_default_is_enabled ( ) {
465+ fn test_s3_allow_invalid_certificates_default_is_none ( ) {
485466 let raw = json ! ( {
486467 "object_store" : "s3" ,
487468 "bucket" : "bucket" ,
@@ -490,45 +471,34 @@ mod tests {
490471 let config: ObjectStoreConfig = serde_json:: from_value ( raw) . unwrap ( ) ;
491472
492473 match config. kind {
493- ObjectStoreKind :: S3 { verify_ssl, .. } => {
494- assert_eq ! ( verify_ssl, None ) ;
474+ ObjectStoreKind :: S3 {
475+ allow_invalid_certificates,
476+ ..
477+ } => {
478+ assert_eq ! ( allow_invalid_certificates, None ) ;
495479 }
496480 _ => panic ! ( "Expected s3 object store kind" ) ,
497481 }
498482 }
499483
500484 #[ test]
501- fn test_s3_verify_ssl_can_be_disabled ( ) {
485+ fn test_s3_allow_invalid_certificates_enabled ( ) {
502486 let raw = json ! ( {
503487 "object_store" : "s3" ,
504488 "bucket" : "bucket" ,
505489 "region_name" : "us-east-1" ,
506- "verify_ssl " : false
490+ "allow_invalid_certificates " : "true"
507491 } ) ;
508492 let config: ObjectStoreConfig = serde_json:: from_value ( raw) . unwrap ( ) ;
509493
510494 match config. kind {
511- ObjectStoreKind :: S3 { verify_ssl, .. } => {
512- assert_eq ! ( verify_ssl, Some ( VerifySSL ( Some ( false ) ) ) ) ;
495+ ObjectStoreKind :: S3 {
496+ allow_invalid_certificates,
497+ ..
498+ } => {
499+ assert_eq ! ( allow_invalid_certificates, Some ( true ) ) ;
513500 }
514501 _ => panic ! ( "Expected s3 object store kind" ) ,
515502 }
516503 }
517-
518- #[ test]
519- fn test_indexer_verify_ssl_env_var_is_parsed ( ) {
520- let env = [
521- ( "METADATA__DATABASE_URL" , "postgresql://localhost" ) ,
522- ( "INDEXER__OBJECT_STORE" , "s3" ) ,
523- ( "INDEXER__BUCKET" , "bucket" ) ,
524- ( "INDEXER__REGION_NAME" , "us-east-1" ) ,
525- ( "INDEXER__VERIFY_SSL" , "false" ) ,
526- ] ;
527-
528- let settings = EnvSettings :: from_map ( HashMap :: from ( env. map ( |( k, v) | ( k. to_string ( ) , v. to_string ( ) ) ) ) ) ;
529- let indexer = settings. indexer . expect ( "indexer settings should be present" ) ;
530-
531- // The object store client is built from env; this test verifies env parsing accepts VERIFY_SSL.
532- assert ! ( indexer. nats_server. is_none( ) ) ;
533- }
534504}
0 commit comments