question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue using AwsIotMqttConnectionConfigBuilder.new_mtls_builder(cert: string, private_key: string) to create MQTT connection

See original GitHub issue

I am currently developing an ios app that uses ionc 5 and angular 9. I am trying to intialize an mqtt connection to the IoT core like this

let config = iot.AwsIotMqttConnectionConfigBuilder.new_mtls_builder(String(args.cert_string), String(args.private_string))
    .with_clean_session(false)
    .with_client_id(this.globals.getVariable("applicationID"))
    .with_endpoint(this.globals.getVariable("aws_endpoint"))
    .with_keep_alive_seconds(6)
    .build();
let client_bootstrap = new io.ClientBootstrap();
let client = new mqtt.MqttClient(client_bootstrap);
let connection = client.new_connection(config);
connection.connect().then((session_present) => {
    console.log("Aws iot connection successful, resuming session:", session_present);
}).catch((error) => {
    console.log("MQTT initialization error:", error);
});

But I am getting this error

MQTT initialization error: TypeError: Cannot read property 'aws_access_id' of undefined
    at create_websocket_url (ws.js:78)
    at Object.create_websocket_stream (ws.js:91)
    at MqttClient.create_websocket_stream [as streamBuilder] (mqtt.js:224)
    at MqttClient._setupStream (client.js:298)
    at new MqttClient (client.js:277)
    at new MqttClientConnection (mqtt.js:233)
    at MqttClient.new_connection (mqtt.js:110)
    at SkalaControlWebsocket.ts:1590
    at t.invoke (polyfills.js:3)
    at Object.onInvoke (core.js:4629)

I am referencing this documentation https://aws.github.io/aws-iot-device-sdk-js-v2/classes/aws_crt.awsiotmqttconnectionconfigbuilder.html. I cannot seem use AwsIotMqttConnectionConfigBuilder.new_mtls_builder to initialize an mqtt client where the certificate and private key are strings. I have made sure that they are in PEM format. Any help would be greatly appreciated. Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ConnorGitHubAccountcommented, Feb 11, 2021

Hi @jmklix I appreciate the quick response time. Yes I have seen #77 and am able to create a MQTT connection the with the AwsIotMqttConnectionConfigBuilder.new_with_websockets() method shown toward the bottom of the post. The only thing about his method is the authentication uses IAM credentials(AWS Access Key Id, AWS Secret access key, and AWS session token). I would like to establish a connection using strings in PEM format of certificate and private key pairs provided by the IoT core. This would be much much more preferable for our application.

1reaction
bretambrosecommented, Feb 24, 2021

If you’re using nodejs then you can make certificate-based mqtt connections to IoT core, but if you’re not, your only option is websockets.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AwsIotMqttConnectionBuilder (AWS IoT Device SDK Java V2)
Create a new builder with mTLS, using a certificate and key stored in the passed-in Java keystore ... newMtlsBuilder​(String certificate, String privateKey).
Read more >
Creating and Using Client Certificates with MQTT and ...
A beginners guide on how to Creatie and Use Client Certificates with MQTT and Mosquitto. Includes example mosquitto configuration file.
Read more >
create-keys-and-certificate — AWS CLI 1.27.32 Command ...
Creates a 2048-bit RSA key pair and issues an X.509 certificate using the ... --private-key-outfile (string) Saves the command output contents of keyPair....
Read more >
Configuring the connection to MQTT
Optionally, you can set this option to provide a path to a CA certificate file in PEM format to authenticate the client with....
Read more >
Client certificate not working in xamarin.android
ToString(); string mqttURI = ""; int mqttPort = 8883; var factory = new ... Maybe there is some issue with constructing certificate in ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found