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?;
Code
Run
This problem seems to be caused by upstream
async-native-tls@0.5
:Am I missing something?
Platform
macOS: 12, 13, 14 Database: