diff --git a/Source/AwsCommonRuntimeKit/mqtt/Mqtt5Options.swift b/Source/AwsCommonRuntimeKit/mqtt/Mqtt5Options.swift index 0f6aecc9..32104784 100644 --- a/Source/AwsCommonRuntimeKit/mqtt/Mqtt5Options.swift +++ b/Source/AwsCommonRuntimeKit/mqtt/Mqtt5Options.swift @@ -55,7 +55,7 @@ public class MqttConnectOptions: CStruct { public let username: String? /// Opaque binary data that the server may use for client authentication and authorization. - public let password: String? + public let password: Data? /// A time interval, in whole seconds, that the client requests the server to persist this connection's MQTT session state for. Has no meaning if the client has not been configured to rejoin sessions. Must be non-zero in order to successfully rejoin a session. If the responding CONNACK contains a session expiry property value, then that is the negotiated session expiry value. Otherwise, the session expiry sent by the client is the negotiated value. public let sessionExpiryInterval: TimeInterval? @@ -84,7 +84,7 @@ public class MqttConnectOptions: CStruct { public init (keepAliveInterval: TimeInterval? = nil, clientId: String? = nil, username: String? = nil, - password: String? = nil, + password: Data? = nil, sessionExpiryInterval: TimeInterval? = nil, requestResponseInformation: Bool? = nil, requestProblemInformation: Bool? = nil, @@ -176,11 +176,12 @@ public class MqttConnectOptions: CStruct { raw_connect_options.user_property_count = userProperties!.count raw_connect_options.user_properties = UnsafePointer(cUserProperties) } - return withOptionalByteCursorPointerFromStrings( - username, password) { cUsernamePointer, cPasswordPointer in + return withOptionalByteCursorPointerFromString(username) { cUsernamePointer in raw_connect_options.username = cUsernamePointer - raw_connect_options.password = cPasswordPointer - return body(raw_connect_options) + return withAWSByteCursorPointerFromOptionalData(to: password) { cPasswordPointer in + raw_connect_options.password = cPasswordPointer + return body(raw_connect_options) + } } } } diff --git a/Test/AwsCommonRuntimeKitTests/mqtt/Mqtt5ClientTests.swift b/Test/AwsCommonRuntimeKitTests/mqtt/Mqtt5ClientTests.swift index 1b8781bb..38124ef8 100644 --- a/Test/AwsCommonRuntimeKitTests/mqtt/Mqtt5ClientTests.swift +++ b/Test/AwsCommonRuntimeKitTests/mqtt/Mqtt5ClientTests.swift @@ -392,7 +392,7 @@ class Mqtt5ClientTests: XCBaseTestCase { let connectOptions = MqttConnectOptions( clientId: createClientId(), username: inputUsername, - password: inputPassword + password: inputPassword.data(using: .utf8) ) let clientOptions = MqttClientOptions( @@ -579,7 +579,7 @@ class Mqtt5ClientTests: XCBaseTestCase { let connectOptions = MqttConnectOptions( clientId: createClientId(), username: inputUsername, - password: inputPassword + password: inputPassword.data(using: .utf8) ) let clientOptions = MqttClientOptions(