How do you reuse streams for tunnel proxy when a tls connection fails

  let stream = match TlsAcceptor::from(server_config)
                            .accept(upgraded)
                            .await
                      {
                          Ok(stream) => stream,
                          Err(err) => {
                              // let upgraded = upgraded.into_inner();
                              // if let Err(err) = tunnel_proxy::tunnel_proxy(upgraded).await {
                              //     eprintln!("Failed to tunnel proxy: {err}");
                              // }
                              // tunnel_proxy::tunnel_proxy(upgraded).await;
                              eprintln!("Failed to build tls stream: {err}");
                              return;
                          }
                      };

I want to write a rust proxy service, but now there is a problem, when the https proxy certificate is wrong, I want to downgrade to a tunnel proxy, but I don't know how to reuse this upgrade flow, can someone help me