Skip to content

Commit 76e5772

Browse files
authored
bindings/c: Don't forward empty encryption key string (#2162)
op-sqlite, for example, always passes the remote encryption key: ``` DB opsqlite_libsql_open_sync(std::string const &name, std::string const &base_path, std::string const &url, std::string const &auth_token, int sync_interval, bool offline, std::string const &encryption_key, std::string const &remote_encryption_key) { ``` Therefore, ensure that remote encryption key is not null and non-empty before passing it as part of HTTP requests.
2 parents a57ad4a + 161c0af commit 76e5772

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bindings/c/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,11 @@ pub unsafe extern "C" fn libsql_open_sync_with_config(
282282
return 5;
283283
}
284284
};
285-
builder = builder.remote_encryption(libsql::EncryptionContext {
286-
key: libsql::EncryptionKey::Base64Encoded(key.to_string()),
287-
});
285+
if !key.is_empty() {
286+
builder = builder.remote_encryption(libsql::EncryptionContext {
287+
key: libsql::EncryptionKey::Base64Encoded(key.to_string()),
288+
});
289+
}
288290
};
289291
match RT.block_on(builder.build()) {
290292
Ok(db) => {

0 commit comments

Comments
 (0)