Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HostCertificateNotFound exception on ES Cloud hosted instance #1

Closed
robin-dojo opened this issue Aug 22, 2022 · 11 comments
Closed

HostCertificateNotFound exception on ES Cloud hosted instance #1

robin-dojo opened this issue Aug 22, 2022 · 11 comments
Labels

Comments

@robin-dojo
Copy link

I am trying to connect to an ES cloud-based instance but I am getting the HostCertificateNotFound exception, however, I don't think this should happen as there would be nowhere for us to add the certificate to the host.

There are some differences in how we create our settings with C# compared to dart:

var settings = EventStoreClientSettings.Create(eventStoreConfiguration.Endpoint);
settings.DefaultCredentials = new UserCredentials(eventStoreConfiguration.Username, eventStoreConfiguration.Password);
var esClient = new EventStoreClient(settings);

I'm not sure if there is another bit of config I need with dart?!

@robin-dojo
Copy link
Author

robin-dojo commented Aug 23, 2022

I have tried adding a ca.crt file to the assets but when giving a path to the publicKeyPath parameter - it's looking in another place. How do I get it to access the assets?

HostCertificateNotFound (HostCertificateNotFound{message: Host certificate file
'/Users/<username>/Library/Containers/com.example.myAppName/Data/certs/ca.crt' not found})

In my pubspec.yaml I have:

flutter:
  assets:
    - lib/images/
    - certs/

@robin-dojo
Copy link
Author

Found an issue with running macOS apps in sandbox - solved one issue - run into another!

@robin-dojo robin-dojo reopened this Aug 23, 2022
@kengu
Copy link
Member

kengu commented Aug 23, 2022

Hi @robin-dojo, the error indicates that TLS is not configured properly in the client, which ES Cloud demands. This involves supplying a public key to the client in the configuration (the client does not support public key exchange automatically), just as yo have tried to do. Unfortunately, the documentation about secure connections are still lacking , and examples does not include this use case. I'll update the examples list soon. The current version of the client does not support the flag tlsVerifyCert that would disable validation of certificates. I'll add this support asap. In the meantime, the only way to work around this issue is to supply a valid crt-file with the ES cluster public key. I don't think the flag tls=false will work with ES Cloud unfortunately. Note that using tlsVerifyCert=false when supported, raise security concerns, since the client will connect to any tls connection on the other side. So you need to find a way to supply the public key as a file if you want the full security of a tls connection to the cluster.

I will also at an option to pass the public key as bytes if files are not an option for you.

@kengu
Copy link
Member

kengu commented Aug 23, 2022

@robin-dojo, see issues #2 and #3

@robin-dojo
Copy link
Author

Thanks @kengu!

I tried to create and use a public key created with the online configurator tool but was then getting an unknown grpc error what I was unable to diagnose. I'll look to see if the certificate was incorrect somehow!

@robin-dojo
Copy link
Author

According to this (if I understand it correctly) you shouldn't need to set up any certs to connect to the ES Cloud clusters.

@kengu
Copy link
Member

kengu commented Aug 24, 2022

Yes, I believe that ES cloud have a public CA with a wildcard certificate that is available (installed) on most client machines (OS-level) already, and is used by Dart to validate TLS connections between the client and ES cloud. I do not have a ES cloud available for testing myself, so I can not confirm it. I will however, do a review of the code again to see if there is something that prevents the use of already installed CAs on the client machine for validation (default trust store).

@kengu
Copy link
Member

kengu commented Aug 24, 2022

It would help if you post any stack traces here for me to analyse

I tried to create and use a public key created with the online configurator tool but was then getting an unknown grpc error what I was unable to diagnose. I'll look to see if the certificate was incorrect somehow!

@kengu
Copy link
Member

kengu commented Aug 24, 2022

@robin-dojo A new version has been released, 0.3.0 supports now tlsVerifyCert=false and uses default trust store on client machine when publicKeyPath is not given.

If this resolves it, please feel free to close this issue as confirmation.

@robin-dojo
Copy link
Author

I'll try this out later today. Thank you for the update!

@robin-dojo
Copy link
Author

This is working a charm with my default trust store 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants