edgedb-dart
edgedb-dart copied to clipboard
Edgedb clientconnect does not seem to work for a flutter application with credentialFile
I am trying to connect from flutter to database on a Mac.
I tried many different approaches, but it seems , that the createCient has an error, as it is set-up to use a SSL connection, while the webserver works with a http connection.
I could not get any configFile, any DSN or credentialFile working.
Using the credentialFile does not work when using edgedb in Flutter.
I changed the code in credential.dart to be able to read the file from the asset folder (see below) and copied the json file to assets and included the file in the assets sections in pubspec.yml. Otherwise the file could not be accessed.
If the credentialFile includes "tls_security": "default" the software throws a connection error:
Connection attempt failed with the following config: ... tlsSecurity TLSSecurity.noHostVerification 'credentialsFile' option
If the credentialFile includes "tls_security": "strict" the software throws a connection error: Connection attempt failed with the following config: ... tlsSecurity TLSSecurity.strict 'credentialsFile' option
I have tried many combinations to connect to the edgedb.
While the webinterface through edgedb ui leads to a http connections, it seems that the connection through the package is trying to build a SSL connection.
Reproduction I used the example code from the example directory, run the instructions and work with the database, that is containing data and can be accessed through the web.
I changed the code in
main.dart
final credentialsFile='assets/<filename>.json';
final client = createClient(
credentialsFile: credentialsFile,
concurrency: 1,
);
pubspec.yml
assets:
- assets/<filename>.json
Change in the library file credentiial.darts
Added
import 'package:flutter/services.dart';
Line 36
final String response=await rootBundle.loadString(file);
final data = await json.decode(response);
return validateCredentials(data);
Expected behavior I want to connect to edgedb from flutter. Once createClient is run, the data should be available in the flutter app. I assume that the connection does not work as SSL for a non SSL setup.
If parameters are set in a file, the error message should conform to the file content and not different settings.
Versions (please complete the following information):
-
OS:
-
EdgeDB version: "2.16+183b29a"
-
EdgeDB CLI version: EdgeDB CLI 3.4.0+4d95a2c
-
edgedb-dart
version: Dart SDK 3.0.6 Flutter SDK 3.10.6 flutter_example 1.0.0+1- edgedb 0.3.0 [crypto path build code_builder dart_style]
-
Dart version: Dart SDK version: 3.0.6 (stable) (Tue Jul 11 18:49:07 2023 +0000) on "macos_arm64"
Additional context Add any other context about the problem here.
Hello,
there were two errors.
First, the Mac OS handshake did not work, here the solution. From Stackoverflow
macOS needs you to request a specific entitlement in order to access the network. To do that open macos/Runner/DebugProfile.entitlements and add the following key-value pair.
Then do the same thing in macos/Runner/Release.entitlements.
This solved the handshake error. Recommendation is to update the file in the next release.
The second issue, was that the certificate checking was not working. As an interim, I have disable config.verifyCert in tcp_proto.dart with this
final sock = await SecureSocket.connect(address.host, address.port,
onBadCertificate: (_) => true,
These two changes allow to work on Mac and IOS apps.