Skip to content

Commit d4849d8

Browse files
authored
Added TLS mismatch information to readme. (#1187)
1 parent 2c44c6a commit d4849d8

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,26 @@ The raw TLS test certs are in [src/test/resources/certs](src/test/resources/cert
10471047
> rm cert.p12 combined.pem
10481048
```
10491049

1050+
### TLS client versus server checks
1051+
1052+
When creating a connection, client TLS behavior is set while creating options.
1053+
The client assumes TLS is requested if there is an SSLContext instance in the options.
1054+
There are two ways one exists:
1055+
1. The user directly supplied one
1056+
2. A default one was created since one was not supplied, but a supplied server url has a secure protocol such as `tls`, `wss` or `opentls`
1057+
1058+
If there is a mismatch, an IOException will be thrown during connect.
1059+
1060+
| server config | client options | result |
1061+
|---------------|-------------------|----------------------------------------------|
1062+
| required | tls not requested | mismatch, "SSL required by server." |
1063+
| available | tls not requested | ok |
1064+
| neither | tls not requested | ok |
1065+
| required | tls requested | ok |
1066+
| available | tls requested | ok |
1067+
| neither | tls requested | mismatch, "SSL connection wanted by client." |
1068+
1069+
10501070
### TLS Handshake First
10511071
In Server 2.10.3 and later, there is the ability to have TLS Handshake First.
10521072

src/main/java/io/nats/client/impl/NatsConnection.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,14 @@ void upgradeToSecureIfNeeded(NatsUri nuri) throws IOException {
681681
dataPort.upgradeToSecure();
682682
}
683683
else {
684+
// server | client options | result
685+
// --------- | ------------------- | --------
686+
// required | not isTLSRequired() | mismatch
687+
// available | not isTLSRequired() | ok
688+
// neither | not isTLSRequired() | ok
689+
// required | isTLSRequired() | ok
690+
// available | isTLSRequired() | ok
691+
// neither | isTLSRequired() | mismatch
684692
ServerInfo serverInfo = getInfo();
685693
if (options.isTLSRequired()) {
686694
if (!serverInfo.isTLSRequired() && !serverInfo.isTLSAvailable()) {

0 commit comments

Comments
 (0)