Skip to content

Commit c04ce42

Browse files
Modify AlpnList if using custom authorizer (#265)
* Added code to use mqtt in alpnList if trying to use custom authorizer * Add back port check to custom authorizer condition
1 parent b33b08c commit c04ce42

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sdk/src/main/java/software/amazon/awssdk/iot/AwsIotMqttConnectionBuilder.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,14 @@ public MqttClientConnection build() {
516516
// This does mean that once you call build() once, modifying the tls context options or client bootstrap
517517
// has no affect on subsequently-created connections.
518518
synchronized(this) {
519+
// Is this going to a custom authorizer at the correct (443) port? If so change the alpnList to "mqtt".
520+
if (config.getUsername() != null) {
521+
if (config.getUsername().contains("x-amz-customauthorizer-name") && config.getPort() == 443) {
522+
tlsOptions.alpnList.clear();
523+
tlsOptions.alpnList.add("mqtt");
524+
}
525+
}
526+
519527
if (tlsOptions != null && (tlsContext == null || resetLazilyCreatedResources)) {
520528
try (ClientTlsContext clientTlsContext = new ClientTlsContext(tlsOptions)) {
521529
swapReferenceTo(tlsContext, clientTlsContext);

0 commit comments

Comments
 (0)