nats.net icon indicating copy to clipboard operation
nats.net copied to clipboard

Usage of the Secure option is unclear

Open tbeets opened this issue 2 years ago • 1 comments

Setting the Secure option to true before connection results in a failed connection. README needs clarification on when the Secure option should be used in an application and additional requirements in the application if Secure option set, e.g. README shows custom configuration of a trust store in example but does not discuss usage of tls:// connection URL, nor default trust store.

For example, if opts.Secure = true; is added to the Publish sample program before CreateConnection() the following exception is thrown:

Exception: A secure connection is requested.
NATS.Client.NATSSecureConnWantedException: A secure connection is requested.
   at NATS.Client.Connection.connect() in /home/todd/lab/fork-nats.net/src/NATS.Client/Conn.cs:line 1202
   at NATS.Client.ConnectionFactory.CreateConnection(Options opts) in /home/todd/lab/fork-nats.net/src/NATS.Client/ConnectionFactory.cs:line 171
   at NATSExamples.Publisher.Run(String[] args) in /home/todd/lab/fork-nats.net/src/Samples/Publish/Publish.cs:line 49
   at NATSExamples.Publisher.Main(String[] args) in /home/todd/lab/fork-nats.net/src/Samples/Publish/Publish.cs:line 131

This is true for both tls://demo.nats.io and nats://demo.nats.io connection URLs.

Without the Secure option, tls://demo.nats.io as URL successfully creates a TLS connection.

tbeets avatar Mar 08 '22 17:03 tbeets

@tbeets I followed the example and cannot reproduce this.

scottf avatar Jun 16 '22 19:06 scottf