I configured the HiveMQ server to recognize TLS and created a TLS communication. I'd like to print out the cipher suites being used. I've used the getSslConfig() but I end up getting this as an output:
Optional[com.hivemq.client.internal.mqtt.MqttClientSslConfigImpl@2710]
I'm aware there is a getCipherSuites()
method in MqttClientSslConfig.java
but I haven't been able to find a way to use it. As a follow up how would I specify a particular cipher suite be used? So far I've just been using the default one like so:
Code (How to specify a particular cipher suite?):
Mqtt5BlockingClient subscriber = Mqtt5Client.builder()
.identifier(UUID.randomUUID().toString()) // the unique identifier of the MQTT client. The ID is randomly generated between
.serverHost("localhost") // the host name or IP address of the MQTT server. Kept it localhost for testing. localhost is default if not specified.
.serverPort(8883) // specifies the port of the server
.addConnectedListener(context -> ClientConnectionRetreiver.printConnected("Subscriber1")) // prints a string that the client is connected
.addDisconnectedListener(context -> ClientConnectionRetreiver.printDisconnected("Subscriber1")) // prints a string that the client is disconnected
.sslWithDefaultConfig() // << How can I specify a particular cipher suite?
.buildBlocking(); // creates the client builder
Code (How I've been trying to get the SSL config) :
Mqtt5ClientConfig clientConfig = client.getConfig();
System.out.println(" Ssl Configuration: " + clientConfig.getSslConfig());
You can configure a specific cipher suite like so:
Mqtt5Client.builder()
...
.sslConfig()
.cipherSuites(Arrays.asList("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"))
.applySslConfig()
...
getSslConfig
returns an Optional
. So to get the cipher suites:
client.getConfig().getSslConfig().get().getCipherSuites()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.