@@ -33,14 +33,15 @@ pub struct NetworkProver {
3333
3434impl NetworkProver {
3535 pub async fn new ( client_config : & ClientCfg ) -> anyhow:: Result < NetworkProver > {
36- let ca_cert_path = client_config. ca_cert_path . to_owned ( ) . expect ( "CA_CERT_PATH must be set" ) ;
37- let cert_path = client_config. cert_path . to_owned ( ) . expect ( "CERT_PATH must be set" ) ;
38- let key_path = client_config. key_path . to_owned ( ) . expect ( "KEY_PATH must be set" ) ;
39- let ssl_config = if ca_cert_path. is_empty ( ) {
36+ let ssl_config = if client_config. ca_cert_path . as_ref ( ) . is_none ( ) {
4037 None
4138 } else {
42- let ( ca_cert, identity) =
43- get_cert_and_identity ( ca_cert_path, cert_path, key_path) . await ?;
39+ let ( ca_cert, identity) = get_cert_and_identity (
40+ client_config. ca_cert_path . as_ref ( ) . expect ( "CA_CERT_PATH not set" ) ,
41+ client_config. cert_path . as_ref ( ) . expect ( "CERT_PATH not set" ) ,
42+ client_config. key_path . as_ref ( ) . expect ( "KEY_PATH not set" ) ,
43+ )
44+ . await ?;
4445 Some ( Config { ca_cert, identity } )
4546 } ;
4647 let endpoint_para = client_config. endpoint . to_owned ( ) . expect ( "ENDPOINT must be set" ) ;
@@ -228,13 +229,13 @@ impl Prover for NetworkProver {
228229}
229230
230231async fn get_cert_and_identity (
231- ca_cert_path : String ,
232- cert_path : String ,
233- key_path : String ,
232+ ca_cert_path : & str ,
233+ cert_path : & str ,
234+ key_path : & str ,
234235) -> anyhow:: Result < ( Option < Certificate > , Option < Identity > ) > {
235- let ca_cert_path = Path :: new ( & ca_cert_path) ;
236- let cert_path = Path :: new ( & cert_path) ;
237- let key_path = Path :: new ( & key_path) ;
236+ let ca_cert_path = Path :: new ( ca_cert_path) ;
237+ let cert_path = Path :: new ( cert_path) ;
238+ let key_path = Path :: new ( key_path) ;
238239 // if !ca_cert_path.is_file() || !cert_path.is_file() || !key_path.is_file() {
239240 // bail!("both ca_cert_path, cert_path and key_path should be valid file")
240241 // }
0 commit comments