Skip to content

Commit 524fb28

Browse files
committed
Document trusted certificate / advertised host mismatch with TLS
1 parent bff2eef commit 524fb28

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
<maven-javadoc-plugin.version>3.11.2</maven-javadoc-plugin.version>
8484
<maven.jar.plugin.version>3.4.2</maven.jar.plugin.version>
8585
<build-helper-maven-plugin.version>3.4.0</build-helper-maven-plugin.version>
86+
<maven-site-plugin.version>3.21.0</maven-site-plugin.version>
8687
<asciidoctor.maven.plugin.version>3.2.0</asciidoctor.maven.plugin.version>
8788
<asciidoctorj.version>3.0.0</asciidoctorj.version>
8889
<asciidoctorj.diagram.version>3.0.1</asciidoctorj.diagram.version>
@@ -422,6 +423,12 @@
422423
</executions>
423424
</plugin>
424425

426+
<plugin>
427+
<groupId>org.apache.maven.plugins</groupId>
428+
<artifactId>maven-site-plugin</artifactId>
429+
<version>${maven-site-plugin.version}</version>
430+
</plugin>
431+
425432
<plugin>
426433
<groupId>org.asciidoctor</groupId>
427434
<artifactId>asciidoctor-maven-plugin</artifactId>

src/docs/asciidoc/api.adoc

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,13 @@ The previous snippet uses a URI that specifies the following information: host,
4949
username, password, and virtual host (`/`, which is encoded as `%2f`).
5050
The URI follows the same rules as the
5151
https://www.rabbitmq.com/uri-spec.html[AMQP 0.9.1 URI],
52-
except the protocol must be `rabbitmq-stream`. <<enabling-tls,TLS is enabled>> by using
53-
the `rabbitmq-stream+tls` scheme in the URI.
52+
except the protocol must be `rabbitmq-stream`.
53+
<<enabling-tls,TLS is enabled>> by using the `rabbitmq-stream+tls` scheme in the URI.
5454

5555
When using one URI, the corresponding node will be the main entry point to connect to. The
5656
`Environment` will then use the stream protocol to find out more about streams topology
57-
(leaders and replicas) when asked to create `Producer` and `Consumer` instances. The `Environment`
58-
may become blind if this node goes down though, so it may be more appropriate to specify
59-
several other URIs to try in case of failure of a node:
57+
(leaders and replicas) when asked to create `Producer` and `Consumer` instances.
58+
The `Environment` may become blind if this node goes down though, so it may be more appropriate to specify several other URIs to try in case of failure of a node:
6059

6160
.Creating an environment with several URIs
6261
[source,java,indent=0]
@@ -75,7 +74,8 @@ Creating the environment to connect to a cluster node works usually seamlessly.
7574
Creating publishers and consumers can cause problems as the client uses hints from the cluster to find the nodes where stream leaders and replicas are located to connect to the appropriate nodes.
7675

7776
These connection hints can be accurate or less appropriate depending on the infrastructure.
78-
If you hit some connection problems at some point – like hostnames impossible to resolve for client applications - this https://www.rabbitmq.com/blog/2021/07/23/connecting-to-streams[blog post] should help you understand what is going on and fix the issues.
77+
If you hit connection problems at some point – like hostnames impossible to resolve for client applications - this https://www.rabbitmq.com/blog/2021/07/23/connecting-to-streams[blog post] should help you understand what is going on and fix the issues.
78+
Setting the `advertised_host` and `advertised_port` https://www.rabbitmq.com/blog/2021/07/23/connecting-to-streams#advertised-host-and-port[configuration entries] should solve the most common connection problems.
7979

8080
To make the local development experience simple, the client library can choose to always use `localhost` for producers and consumers.
8181
This happens if the following conditions are met: the initial host to connect to is `localhost`, the user is `guest`, and no custom address resolver has been provided.
@@ -88,13 +88,10 @@ TLS can be enabled by using the `rabbitmq-stream+tls` scheme in the URI.
8888
The default TLS port is 5551.
8989

9090
Use the `EnvironmentBuilder#tls` method to configure TLS.
91-
The most important setting is a `io.netty.handler.ssl.SslContext` instance, which is created and configured with the
92-
`io.netty.handler.ssl.SslContext#forClient` method.
91+
The most important setting is a `io.netty.handler.ssl.SslContext` instance, which is created and configured with the `io.netty.handler.ssl.SslContext#forClient` method.
9392
Note hostname verification is enabled by default.
9493

95-
The following snippet shows a common configuration, whereby
96-
the client is instructed to trust servers with certificates
97-
signed by the configured certificate authority (CA).
94+
The following snippet shows a common configuration, whereby the client is instructed to trust servers with certificates signed by the configured certificate authority (CA).
9895

9996
.Creating an environment that uses TLS
10097
[source,java,indent=0]
@@ -106,10 +103,14 @@ include::{test-examples}/EnvironmentUsage.java[tag=environment-creation-with-tls
106103
<3> Use TLS scheme in environment URI
107104
<4> Set `SslContext` in environment configuration
108105

109-
It is sometimes handy to trust any server certificates
110-
in development environments. `EnvironmentBuilder#tls` provides the
111-
`trustEverything` method to do so. **This should
112-
not be used in a production environment**.
106+
Checking the identity of the server the client connects to is an important part of the TLS handshake.
107+
To make this work with the stream client library, it is critical the configured trusted certificates match the hosts returned by cluster nodes in the connection hints.
108+
Make sure to read the section on <<understanding-connection-logic, connection logic>>.
109+
You may have to configure the `advertised_tls_host` https://www.rabbitmq.com/blog/2021/07/23/connecting-to-streams#advertised-host-and-port[broker setting] in case of a mismatch between trusted certificates and the default connection hints cluster nodes return.
110+
111+
It is sometimes handy to trust any server certificates in development environments.
112+
`EnvironmentBuilder#tls` provides the `trustEverything` method to do so.
113+
**This should not be used in a production environment**.
113114

114115
.Creating a TLS environment that trusts all server certificates for development
115116
[source,java,indent=0]

0 commit comments

Comments
 (0)