prisma / tiberius

TDS 7.2+ (Microsoft SQL Server) driver for Rust
Apache License 2.0
325 stars 119 forks source link

BUG: native-tls connection no response for a long time #318

Closed wyhaya closed 11 months ago

wyhaya commented 11 months ago

Code

async main() {
    let mut config = Config::default();
    config.host("127.0.0.1");
    config.port(1433);
    config.authentication(AuthMethod::sql_server("sa", "Abc123456."));
    config.encryption(EncryptionLevel::On);
    config.trust_cert();

    let tcp = TcpStream::connect(config.get_addr()).await?;
    tcp.set_nodelay(true)?;

    let client = Client::connect(config, tcp.compat_write()).await?;
    println!("Connect success");
}

Run

# rustls: Connect success
cargo run --example tokio --no-default-features --features rustls

# openssl: Connect success
cargo run --example tokio --no-default-features --features vendored-openssl

# native-tls:
# `Client::connect` Always running but no response, no any error
cargo run --example tokio --no-default-features --features native-tls

This problem seems to be caused by upstream async-native-tls@0.5:

let mut builder = TlsConnector::new();
builder = builder.danger_accept_invalid_certs(true);
builder = builder.danger_accept_invalid_hostnames(true);
builder = builder.use_sni(false);

// OK
let stream = TcpStream::connect("127.0.0.1:1433").await?;

// Always running but no response, no any error
let tls_stream = builder.connect("127.0.0.1:1433", stream).await?;

Am I missing something?

Platform

macOS: 12, 13, 14 Database:

docker run -idt --name mssql \
        -e ACCEPT_EULA=Y \
        -e MSSQL_SA_PASSWORD='Abc123456.'  \
        -p 1433:1433  \
        mcr.microsoft.com/azure-sql-edge
wyhaya commented 11 months ago

This is mentioned in READMD and I missed it .