Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in TlsAcceptor::new casue panic #2067

Closed
TCeason opened this issue Nov 25, 2024 · 1 comment
Closed

Bug in TlsAcceptor::new casue panic #2067

TCeason opened this issue Nov 25, 2024 · 1 comment

Comments

@TCeason
Copy link

TCeason commented Nov 25, 2024

Bug Report

Version

master

Platform

Crates

tonic = { version = "0.12.3", features = ["transport", "codegen", "prost", "tls-roots", "tls"] }
tonic-build = { version = "0.12.3" }
tonic-reflection = { version = "0.12.3" }

Description

in TlsConnector::new create build with provider but in TlsAcceptor::new use old ServerConfig::builder it cause panic:

 no process-level CryptoProvider available -- call CryptoProvider::install_default() before this point
impl TlsAcceptor {
    pub(crate) fn new(
        identity: Identity,
        client_ca_root: Option<Certificate>,
        client_auth_optional: bool,
    ) -> Result<Self, crate::BoxError> {
        let builder = ServerConfig::builder();
impl TlsConnector {
    pub(crate) fn new(
        ca_certs: Vec<Certificate>,
        trust_anchors: Vec<TrustAnchor<'static>>,
        identity: Option<Identity>,
        domain: &str,
        assume_http2: bool,
        #[cfg(feature = "tls-native-roots")] with_native_roots: bool,
        #[cfg(feature = "tls-webpki-roots")] with_webpki_roots: bool,
    ) -> Result<Self, crate::BoxError> {
        fn with_provider(
            provider: Arc<crypto::CryptoProvider>,
        ) -> ConfigBuilder<ClientConfig, WantsVerifier> {
            ClientConfig::builder_with_provider(provider)
                .with_safe_default_protocol_versions()
                .unwrap()
        }

        #[allow(unreachable_patterns)]
        let builder = match crypto::CryptoProvider::get_default() {
            Some(provider) => with_provider(provider.clone()),
            #[cfg(feature = "tls-ring")]
            None => with_provider(Arc::new(crypto::ring::default_provider())),
            #[cfg(feature = "tls-aws-lc")]
            None => with_provider(Arc::new(crypto::aws_lc_rs::default_provider())),
            // somehow tls is enabled, but neither of the crypto features are enabled.
            _ => ClientConfig::builder(),
        };
@TCeason
Copy link
Author

TCeason commented Nov 25, 2024

Ref the tonci part:

---- servers::flight::flight_service::test_tls_rpc_server stdout ----
thread 'servers::flight::flight_service::test_tls_rpc_server' panicked at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustls-0.23.18/src/crypto/mod.rs:249:14:
no process-level CryptoProvider available -- call CryptoProvider::install_default() before this point
stack backtrace:
   0: rust_begin_unwind
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/panicking.rs:661:5
   1: core::panicking::panic_fmt
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/core/src/panicking.rs:74:14
   2: core::panicking::panic_display
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/core/src/panicking.rs:264:5
   3: core::option::expect_failed
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/core/src/option.rs:2023:5
   4: core::option::Option<T>::expect
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/core/src/option.rs:926:21
   5: rustls::crypto::CryptoProvider::get_default_or_install_from_crate_features
             at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustls-0.23.18/src/crypto/mod.rs:248:24
   6: rustls::server::server_conn::ServerConfig::builder_with_protocol_versions
             at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustls-0.23.18/src/server/server_conn.rs:438:13
   7: rustls::server::server_conn::ServerConfig::builder
             at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustls-0.23.18/src/server/server_conn.rs:415:9
   8: tonic::transport::server::service::tls::TlsAcceptor::new
             at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tonic-0.12.3/src/transport/server/service/tls.rs:26:23
   9: tonic::transport::server::tls::ServerTlsConfig::tls_acceptor
             at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tonic-0.12.3/src/transport/server/tls.rs:60:9
  10: tonic::transport::server::Server<L>::tls_config
             at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tonic-0.12.3/src/transport/server/mod.rs:160:23
  11: databend_query::servers::flight::flight_service::FlightService::start_with_incoming::{{closure}}::{{closure}}
             at ./src/servers/flight/flight_service.rs:69:13
  12: <async_backtrace::framed::Framed<F> as core::future::future::Future>::poll::{{closure}}
             at /home/eason/.cargo/git/checkouts/async-backtrace-9554bf0eaadc9fb8/dea4553/backtrace/src/framed.rs:49:27
  13: async_backtrace::frame::Frame::in_scope::{{closure}}
             at /home/eason/.cargo/git/checkouts/async-backtrace-9554bf0eaadc9fb8/dea4553/backtrace/src/frame.rs:184:17
  14: std::thread::local::LocalKey<T>::try_with
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/thread/local.rs:283:12
  15: std::thread::local::LocalKey<T>::with
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/thread/local.rs:260:9
  16: async_backtrace::frame::active_frame::with
             at /home/eason/.cargo/git/checkouts/async-backtrace-9554bf0eaadc9fb8/dea4553/backtrace/src/frame.rs:81:9
  17: async_backtrace::frame::Frame::in_scope
             at /home/eason/.cargo/git/checkouts/async-backtrace-9554bf0eaadc9fb8/dea4553/backtrace/src/frame.rs:180:13
  18: <async_backtrace::framed::Framed<F> as core::future::future::Future>::poll
             at /home/eason/.cargo/git/checkouts/async-backtrace-9554bf0eaadc9fb8/dea4553/backtrace/src/framed.rs:49:9
  19: databend_query::servers::flight::flight_service::FlightService::start_with_incoming::{{closure}}
             at ./src/servers/flight/flight_service.rs:63:5
  20: <databend_query::servers::flight::flight_service::FlightService as databend_query::servers::server::Server>::start::{{closure}}::{{closure}}
             at ./src/servers/flight/flight_service.rs:104:40
  21: <async_backtrace::framed::Framed<F> as core::future::future::Future>::poll::{{closure}}
             at /home/eason/.cargo/git/checkouts/async-backtrace-9554bf0eaadc9fb8/dea4553/backtrace/src/framed.rs:49:27
  22: async_backtrace::frame::Frame::in_scope::{{closure}}
             at /home/eason/.cargo/git/checkouts/async-backtrace-9554bf0eaadc9fb8/dea4553/backtrace/src/frame.rs:184:17
  23: std::thread::local::LocalKey<T>::try_with
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/thread/local.rs:283:12
  24: std::thread::local::LocalKey<T>::with
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/std/src/thread/local.rs:260:9
  25: async_backtrace::frame::active_frame::with
             at /home/eason/.cargo/git/checkouts/async-backtrace-9554bf0eaadc9fb8/dea4553/backtrace/src/frame.rs:81:9
  26: async_backtrace::frame::Frame::in_scope
             at /home/eason/.cargo/git/checkouts/async-backtrace-9554bf0eaadc9fb8/dea4553/backtrace/src/frame.rs:180:13
  27: <async_backtrace::framed::Framed<F> as core::future::future::Future>::poll
             at /home/eason/.cargo/git/checkouts/async-backtrace-9554bf0eaadc9fb8/dea4553/backtrace/src/framed.rs:49:9
  28: <databend_query::servers::flight::flight_service::FlightService as databend_query::servers::server::Server>::start::{{closure}}
             at ./src/servers/flight/flight_service.rs:102:5
  29: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/core/src/future/future.rs:123:9
  30: it::servers::flight::flight_service::test_tls_rpc_server::{{closure}}
             at ./tests/it/servers/flight/flight_service.rs:46:60
  31: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/core/src/future/future.rs:123:9
  32: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
             at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/park.rs:281:63
  33: tokio::runtime::coop::with_budget
             at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/coop.rs:107:5
  34: tokio::runtime::coop::budget
             at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/coop.rs:73:5
  35: tokio::runtime::park::CachedParkThread::block_on
             at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/park.rs:281:31
  36: tokio::runtime::context::blocking::BlockingRegionGuard::block_on
             at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/context/blocking.rs:66:9
  37: tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}
             at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/scheduler/multi_thread/mod.rs:87:13
  38: tokio::runtime::context::runtime::enter_runtime
             at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/context/runtime.rs:65:16
  39: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
             at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/scheduler/multi_thread/mod.rs:86:9
  40: tokio::runtime::runtime::Runtime::block_on_inner
             at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/runtime.rs:370:45
  41: tokio::runtime::runtime::Runtime::block_on
             at /home/eason/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/runtime.rs:342:13
  42: it::servers::flight::flight_service::test_tls_rpc_server
             at ./tests/it/servers/flight/flight_service.rs:66:5
  43: it::servers::flight::flight_service::test_tls_rpc_server::{{closure}}
             at ./tests/it/servers/flight/flight_service.rs:37:35
  44: core::ops::function::FnOnce::call_once
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/core/src/ops/function.rs:250:5
  45: core::ops::function::FnOnce::call_once
             at /rustc/cf2df68d1f5e56803c97d91e2b1a9f1c9923c533/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    servers::flight::flight_service::test_tls_rpc_server

test result: FAILED. 2 passed; 1 failed; 0 ignored; 0 measured; 222 filtered out; finished in 0.75s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant