aws / aws-iot-device-sdk-embedded-C

SDK for connecting to AWS IoT from a device using embedded C.
MIT License
978 stars 625 forks source link

mqtt_demo_mutual_auth SSL_Read failed #1803

Closed avrono closed 2 years ago

avrono commented 2 years ago

I have built the embedded c SDK on a Raspberry Pi Zero W running Raspberry Pi OS Lite

I keep getting the below error , I have run open SSL client openssl s_client -connect xxx-ats.iot.us-west-2.amazonaws.com:8883 -CAfile ~/certs/root-CA.crt -cert ~/certs/AvronPiZeroW-1.cert.pem -key ~/certs/AvronPiZeroW-1.private.key which Verifies OK

I also tried using the Mosquito_pub which fails to connect

mosquitto_pub -d -p 8883 -t "sdk/test/Python" --cafile root-CA.crt --cert AvronPiZeroW-1.cert.pem --key AvronPiZeroW-1.private.key -i AvronPiZeroW-1 -h xxxx-ats.iot.us-west-2.amazonaws.com -m "Hello" Client AvronPiZeroW-1 sending CONNECT Error: The connection was lost.

The Python SDK , running basicPubSub works ok and I can see messages being received.

I have checked the policies and certificates associated with the device and all seems ok.

[INFO] [DEMO] [mqtt_demo_mutual_auth.c:642] Establishing a TLS session to xxx-ats.iot.us-west-2.amazonaws.com:8883. [ERROR] [Transport_OpenSSL_Sockets] [openssl_posix.c:815] Failed to receive data over network: SSL_read failed: ErrorStatus=EVP lib. [ERROR] [MQTT] [core_mqtt_serializer.c:2400] A single byte was not read from the transport: transportStatus=-1. [ERROR] [MQTT] [core_mqtt.c:1569] CONNACK recv failed with status = MQTTRecvFailed. [ERROR] [MQTT] [core_mqtt.c:1840] MQTT connection failed with status = MQTTRecvFailed. [ERROR] [DEMO] [mqtt_demo_mutual_auth.c:1125] Connection with MQTT broker failed with status MQTTRecvFailed. [WARN] [DEMO] [mqtt_demo_mutual_auth.c:681] Connection to the broker failed. Retrying connection after 26 ms backoff. [INFO] [DEMO] [mqtt_demo_mutual_auth.c:642] Establishing a TLS session to xxx-ats.iot.us-west-2.amazonaws.com:8883. [ERROR] [Transport_OpenSSL_Sockets] [openssl_posix.c:815] Failed to receive data over network: SSL_read failed: ErrorStatus=EVP lib.

avrono commented 2 years ago

Turns out this was an issue with Policies.