此内容没有您所选择的语言版本。
Chapter 5. Connecting external clients to templates-based broker deployments
5.1. Configuring SSL 复制链接链接已复制到粘贴板!
For a minimal SSL configuration to allow connections outside of OpenShift Container Platform, AMQ Broker requires a broker keystore, a client keystore, and a client truststore that includes the broker keystore. The broker keystore is also used to create a secret for the AMQ Broker on OpenShift Container Platform image, which is added to the service account.
The following example commands use Java KeyTool, a package included with the Java Development Kit, to generate the necessary certificates and stores.
For a more complete example of deploying a broker instance that supports SSL, see Deploying a basic broker with SSL.
Procedure
Generate a self-signed certificate for the broker keystore:
keytool -genkey -alias broker -keyalg RSA -keystore broker.ks
$ keytool -genkey -alias broker -keyalg RSA -keystore broker.ksCopy to Clipboard Copied! Toggle word wrap Toggle overflow Export the certificate so that it can be shared with clients:
keytool -export -alias broker -keystore broker.ks -file broker_cert
$ keytool -export -alias broker -keystore broker.ks -file broker_certCopy to Clipboard Copied! Toggle word wrap Toggle overflow Generate a self-signed certificate for the client keystore:
keytool -genkey -alias client -keyalg RSA -keystore client.ks
$ keytool -genkey -alias client -keyalg RSA -keystore client.ksCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a client truststore that imports the broker certificate:
keytool -import -alias broker -keystore client.ts -file broker_cert
$ keytool -import -alias broker -keystore client.ts -file broker_certCopy to Clipboard Copied! Toggle word wrap Toggle overflow Export the client’s certificate from the keystore:
keytool -export -alias client -keystore client.ks -file client_cert
$ keytool -export -alias client -keystore client.ks -file client_certCopy to Clipboard Copied! Toggle word wrap Toggle overflow Import the client’s exported certificate into a broker SERVER truststore:
keytool -import -alias client -keystore broker.ts -file client_cert
$ keytool -import -alias client -keystore broker.ts -file client_certCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.2. Generating the AMQ Broker secret 复制链接链接已复制到粘贴板!
The broker keystore can be used to generate a secret for the namespace, which is also added to the service account so that the applications can be authorized.
Procedure
At the command line, run the following commands:
oc create secret generic <secret-name> --from-file=<broker-keystore> --from-file=<broker-truststore> oc secrets add sa/<service-account-name> secret/<secret-name>
$ oc create secret generic <secret-name> --from-file=<broker-keystore> --from-file=<broker-truststore> $ oc secrets add sa/<service-account-name> secret/<secret-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.3. Creating an SSL Route 复制链接链接已复制到粘贴板!
After the AMQ Broker on OpenShift Container Platform image has been deployed, you need to create an SSL Route for the AMQ Broker transport protocol port to allow connections to AMQ Broker outside of OpenShift. You can only expose SSL Routes because the OpenShift router requires SNI to send traffic to the correct Service.
Selecting Passthrough for TLS Termination relays all communication to AMQ Broker without the OpenShift router decrypting and resending it.
Regular HTTP traffic does not require a TLS passthrough Route because the OpenShift router uses HAProxy, which is a HTTP proxy.
External clients for AMQ Broker on OpenShift Container Platform must specify the OpenShift router port (443, by default) when setting the broker URL for SSL connections. Otherwise, AMQ Broker attempts to use the default SSL port (61617).
By default, the OpenShift router uses port 443. However, the router might be configured to use a different port number, based on the value specified for the ROUTER_SERVICE_HTTPS_PORT environment variable. For more information, see OpenShift Container Platform 4.1 Routes.
Also, including the failover protocol in the URL preserves the client connection in case the pod is restarted or upgraded, or a disruption occurs on the router. Both of these settings are shown below.
...
factory.setBrokerURL("failover://ssl://<route-to-broker-pod>:443");
...
...
factory.setBrokerURL("failover://ssl://<route-to-broker-pod>:443");
...
External clients do not support HA.
The default ports for the various AMQ Broker transport protocols are shown in the table.
| AMQ Broker transport protocol | Default port |
|---|---|
| All protocols (OpenWire, AMQP, STOMP, MQTT, and HornetQ) | 61616 |
| All protocols -SSL (OpenWire AMQP, STOMP, MQTT, and HornetQ) | 61617 |
| AMQP | 5672 |
| AMQP -SSL | 5671 |
| MQTT | 1883 |
| MQTT -SSL | 8883 |
| STOMP | 61613 |
| STOMP -SSL | 61612 |
Additional resources
- For more information on cluster networking, see Secured Routes.