To connect with AWS IoT broker in iOS - ios

We are developing an application which needs to consume AWS IoT service based on a MQTT protocol deviation. We are currently facing issues to get connected with MQTT broker provided by AWS IoT cloud server.
Following is the environment:
iOS Version: 8.0 / 9.0
Programming language: Swift
Library for MQTT: Moscapsule
Steps followed:
Set initial config clientid, host, port
Set client certificate with private key, providing .pem file path (e.g. cert.pem, privateKey.pem)
Set server certificate which is root certificate .pem file path (e.g. rootCA.pem)
Set tls opts with tsl_insecure: false, cert_reqs: SSL_VERIFY_PEER, tls version: tlsv1.2, ciphers: nil
Problems faced:
When trying to connect to server/broker gives error “unable to create TLS_Context”.
With setting tls cert_reqs: SSL_VERIFY_NONE, gives connection status success with subcribe and publish sucess, but doesn’t reflect on server or broker.
Any help in this context is highly appreciable.

The AWS SDK for iOS already supports connecting to AWS IoT over MQTT. You can see an example Swift program which transfers data to and from AWS IoT over MQTT using certificate-based authentication here. If you'd like to use a different MQTT client and just need to know how to set it up, you might start with the AWS SDK for iOS, and then have a look at the code involved in setting up the TLS connection.
Thanks for using AWS IoT.

Related

Unsupported attribute 27 in CoA-Request from IP:PORT

I have a freeradius server setup on my ubuntu VM. My Edgecore AP is connected to a MicroTik and Laptop. I have OpenWRT running on the AP and I'm able to connect a client using WPA2 Enterprise encryption. I'm trying to send a CoA request from the VM such as "Session-Timeout" however, observing the logs on the AP, I receive the message I've included in the title. Is CoA completely unsupported or hostapd simply can't understand the incoming request?
Dynamic Authorization Extensions (RFC 5176) is default disabled in hostapd.
set radius_das_port=3799 in your conf to enable this feature.
https://web.mit.edu/freebsd/head/contrib/wpa/hostapd/hostapd.conf

Unable to login to Azure IoT Hub with cellular MQTT AT command

I'm using a u-Blox SARA-R422M8S cellular module trying to connect to Azure Iot Hub with the MQTT AT commands. The module supports MQTT 3.1.1. The login request fails with Broker connection refused, not authorized. Using the same credentials in the python example at Microsoft Azure documentation, the login succeeds and I can publish. I've uploaded the Baltimore root cert and activated the TLS for the socket, so this seems ok as well as I get another error code elsewise.
Anyone experienced similar?
PS, here are the AT commands used:
AT+USECPRF=0
AT+USECPRF=0,0,1
AT+USECPRF=0,3,"root_ca"
AT+UPSD=0,0,0
AT+UPSD=0,100,1
AT+UMQTT=11,1,0
AT+UMQTT=2,".azure-devices.net",8883
AT+UMQTT=4,"myhub.azure-devices.net/mydev/?api-version=2018-06-30","mysas""
As per the docs:
For the ClientId field, use the deviceId.
So you need to set the Client ID with something like:
AT+UMQTT=0,"mydev"

How to configure MQTT mosquitto with TPM engine

I have configured MQTT Mosquitto and enabled SSL and i have connected securely using certificates cafile, certfile and keyfile tested using MQTT.FX client.
The problem is , is there any way to enable TPM engine which can store certificates in it and connect to MQTT client.
I have refered this link
https://mosquitto.org/man/mosquitto-conf-5.html
This is an OpenSSL capability that Mosquitto is just exposing some of the config for.
Have a look at something like this which is a plugin to add TPM2.0 support

Run gRPC server on iOS

Is it possible to run a gRPC server on iOS?
Let’s say we want to use the gRPC framework to define APIs etc. And now we want to deploy a gRPC server in the same process with the application using it — connection via an InprocessChannel.
Is there a gRPC port for iOS that allows to do that?
Yes, unlike with the Objective-C bindings for gRPC, it's possible to run a gRPC server on iOS using Swift GRPC:
APIs and generated code is provided for both gRPC clients and servers,
and can be built either with Xcode or the Swift Package Manager.
Support is provided for all four gRPC API styles (Unary, Server
Streaming, Client Streaming, and Bidirectional Streaming) and
connections can be made either over secure (TLS) or insecure channels.
The Echo example contains a Mac app that demonstrates both server and client code. The Swift gRPC parts should be similar in an iOS app.
It is not officially supported by gRPC, but you have a couple of options to do this on your own:
You can wrap gRPC C++ and use their server feature. Someone tried this before and seems worked.
You can use the gRPC Swift repo which has gRPC server feature on iOS client.

using Azure IoT Hub as a MQTT broker

Our Current Deployment:
1) several back-end devices running an MQTT client connect to an opensource MQTT broker (Mosquitto)
2) Mosquitto is running on a Linux VM and acts as a broker and a communication point between back-end & front-end devices.
3) Several front-end devices (Mobile App / browser based GUI) connect to the broker. some of the front-end devices read & write to the broker (Sub & Pub) while some front-end only read (Sub)
4) Some front-end devices connect for a few minutes & some front ends are always connected.
5) Although the amount of data being transferred is a few kb, it is sometimes fast changing.
6) No TLS is used for the MQTT traffic & it cannot be enabled on the back-end devices.
This setup works for us, but I am looking for a way to scale up and was considering the azure IoT hub, but I am confused if the IoT hub can be used as a broker or I would need additional components to be deployed for acting as a MQTT broker ?
Azure IoT Hub is not a generic MQTT Broker. There is a built-in the device communications for MQTT protocol. More details can be found in the Using the MQTT protocol directly
For exploring the MQTT Devices (virtual devices) with the Azure IoT Hub (without the coding) can be used a small tool Azure IoT Hub Tester

Resources