prisma / tiberius

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

macOS 15 + SQL Server 2014 doesn't work #364

Open kzhui125 opened 1 month ago

kzhui125 commented 1 month ago

I have tested rustls/vendored-openssl feature, it doesn't work for macOS 15 connecting to SQL Server 2014 in Windows Server 2012 R2

[target.'cfg(not(windows))'.dependencies.tiberius]
version = "0.12"
default-features = false
features = ["rustls", "tds73", "winauth", "chrono", "rust_decimal"]
NTmatter commented 1 month ago

Can you share the error you're seeing? That might help narrow things down.

Out of curiousity, does it work without the winauth feature?

kzhui125 commented 1 month ago
[dependencies]
tiberius = { version = "0.12", default-features = false, features = [
    # "rustls",
    # "native-tls",
    "vendored-openssl",
    "tds73",
] }
tokio = { version = "1", features = ["full"] }
tokio-util = { version = "0.7", features = ["compat"] }

tested without winauth, and tested with rustls, native-tls, vendored-openssl

use tiberius::{AuthMethod, Client, Config, EncryptionLevel};
use tokio::net::TcpStream;
use tokio_util::compat::TokioAsyncWriteCompatExt;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut config = Config::new();

    config.host("192.168.50.74");
    config.port(1433);
    config.authentication(AuthMethod::sql_server("user", "password"));
    config.encryption(EncryptionLevel::Off);
    config.trust_cert();

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

    let _client = match Client::connect(config, tcp.compat_write()).await {
        // Connection successful.
        Ok(client) => client,
        Err(e) => Err(e)?,
    };

    Ok(())
}

rustls

Error: Io { kind: UnexpectedEof, message: "tls handshake eof" }

native-tls

get error after long time:

Error: Tls("connection closed via error")

vendored-openssl

Error: Tls("unexpected EOF")

version:

sql server version:

SELECT @@VERSION
Microsoft SQL Server 2014 (SP2) (KB3171021) - 12.0.5000.0 (X64)   Jun 17 2016 19:14:09   Copyright (c) Microsoft Corporation  Enterprise Edition (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor) 

openssl:

openssl -v
OpenSSL 3.3.2 3 Sep 2024 (Library: OpenSSL 3.3.2 3 Sep 2024)
image

Thanks @NTmatter