tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.

Home Page:https://turso.tech/libsql

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[C Bindings] open remote connection fails with CA certificates on Android

ospfranco opened this issue · comments

I seem to have hit this issue:

rustls/hyper-rustls#187

Here a user tried to connect to a turso remote database on Android:

OP-Engineering/op-sqlite#102 (comment)

The proposed solution is using a different API which has been made available only on Rust:

#789

On rust the open_remote_with_connector function has been exposed, which does not use root certificates but webpki. I guess I would also need the same function exposed to the C bindings.

This is what you have to do to get this working on Android:

let https = hyper_rustls::HttpsConnectorBuilder::new()
                    .with_webpki_roots()
                    .https_or_http()
                    .enable_http1()
                    .build();
            Builder::new_remote_replica(db_file, url, auth_token)
                    .connector(https)
                    .build()
                    .await

I guess I could expose a new C function just for Android that would do the above internally.

You should be able to use libql_open_sync_with_webpki and libsql_open_remote_with_webpki introduced in #1433

awesome. thanks!