WasmEdge / wasmedge-db-examples

Lightweight database clients in the WasmEdge Runtime
Apache License 2.0
64 stars 10 forks source link

TLS issue with mysql_async_wasi #18

Open sunng87 opened 9 months ago

sunng87 commented 9 months ago

Since the mysql_async_wasi repo does not have an issue track, I'm reporting to this repo instead.

When testing greptimedb example against GreptimeCloud instance, we are not able to complete SSL handshake. But using the original mysql_async library for default linux target, with default-rustls feature enabled, it works smoothly. So I believe there is potential issue with our mysql_async fork or tls libraries.

Steps to reproduce

  1. Create a GreptimeDB instance on GreptimeCloud, copy all those connection information: host, dbname, username, password
  2. Compile greptimedb example in this repo, and execute with wasmedge --env "DATABASE_URL=mysql://<username>:<password>@<host>:4002/<dbname>" --env "DATABASE_SSL=1" target/wasm32-wasi/debug/greptimedb.wasm
  3. Blocked with no output

What I can see from wireshark (no outbound traffic captured) image There is no traffic after mysql server greeting.

Verify from default target

  1. Change dependency to original mysql_async 0.31 and tokio 1.0, set build target to default
  2. Build the project and run

The example executed successfully and wireshark shows encrypted traffic. image

DATABASE_URL=mysql://<username>:<password>@<host>:4002/<dbname> DATABASE_SSL=1 target/debug/greptimedb                                                                                                       
Table created!
Ingest some data...
Query some data
[CpuMetric { hostname: "host0", environment: "test", usage_user: 32.0, usage_system: 3.0, usage_idle: 4.0, ts: 1680307200000 }, CpuMetric { hostname: "host0", environment: "test", usage_user: 32.0, usage_system: 3.0, usage_idle: 4.0, ts: 1680307260000 }, CpuMetric { hostname: "host0", environment: "test", usage_user: 32.0, usage_system: 3.0, usage_idle: 4.0, ts: 1680307320000 }, CpuMetric { hostname: "host1", environment: "test", usage_user: 29.0, usage_system: 32.0, usage_idle: 50.0, ts: 1680307200000 }, CpuMetric { hostname: "host1", environment: "test", usage_user: 29.0, usage_system: 32.0, usage_idle: 50.0, ts: 1680307260000 }, CpuMetric { hostname: "host1", environment: "test", usage_user: 29.0, usage_system: 32.0, usage_idle: 50.0, ts: 1680307320000 }]
L-jasmine commented 9 months ago

I've encountered this error, and I will update the rustls plugin to attempt to resolve it.

https://github.com/rustls/rustls/blob/303b3ff97d47e8802392d45217c8cf358e6ed879/rustls/src/error.rs#L312-L313