espressif / esp-aws-iot

AWS IoT SDK for ESP32 based chipsets
Apache License 2.0
256 stars 153 forks source link

error in corePKCS11 using fleet provisioning example (CA-292) #182

Open luisangelMV opened 1 year ago

luisangelMV commented 1 year ago

I'm trying to use the fleet provisioning example, but I always get the corePKCS11 error

esp-idf version: 5.0.2

dev board: esp32-devkitt-v1

console log: I (11902) corePKCS11: PKCS #11 successfully initialized. I (11922) corePKCS11: Creating a 0x3 type object. I (11922) PKCS11: Initializing NVS partition: "storage" E (11952) corePKCS11: Failed to destroy object. PKCS11_PAL_DestroyObject failed. I (11952) corePKCS11: Writing certificate into label "Claim Cert". I (11962) corePKCS11: Creating a 0x1 type object. I (11972) FleetProvisioning: Establishing MQTT session with claim certificate... I (13362) wifi:idx:0 (ifx:0, b0:08:75:71:7c:4c), tid:0, ssn:798, winSize:64 I (15112) coreMQTT: MQTT connection established with the broker. I (15112) FleetProvisioning: Established connection with claim credentials. I (16162) coreMQTT: Ack packet deserialized with result: MQTTSuccess. I (16162) coreMQTT: State record updated. New state=MQTTPublishDone. I (16342) coreMQTT: De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess. I (16342) coreMQTT: State record updated. New state=MQTTPubAckSend. I (16342) FleetProvisioning: Received accepted response from Fleet Provisioning CreateCertificateFromCsr API. I (19392) FleetProvisioning: Received certificate with Id: e67e46cf6864dcad1f6ccbdaed37778ba598160772c8765d370a99860405ce33 I (19432) corePKCS11: Writing certificate into label "Device Cert". I (19432) corePKCS11: Creating a 0x1 type object. E (20332) Transport_MbedTLS_PKCS11: Failed to read data: mbedTLSError= SSL - The peer notified us that the connection is going to be closed : . E (20332) coreMQTT: Call to receiveSingleIteration failed. Status=MQTTRecvFailed E (20342) coreMQTT: MQTT_ProcessLoop failed to receive ACK packet: Expected ACK Packet ID=06, LoopDuration=304, Status=MQTTRecvFailed E (20352) FleetProvisioning: Failed to subscribe to fleet provisioning topic: $aws/provisioning-templates/marhtprovisiontemplate/provision/cbor/accepted. I (20372) coreMQTT: Disconnected from the broker. I (20382) corePKCS11: Successfully closed PKCS #11 session. I (20382) corePKCS11: PKCS #11 was successfully uninitialized.

mksafavi commented 7 months ago

I had the same issue. E (20352) FleetProvisioning: Failed to subscribe to fleet provisioning topic: $aws/provisioning-templates/FleetProvisioningDemoTemplate/provision/cbor/accepted.

I fixed it by setting the template name to the same string. If I remember correctly, you have to set the name in provisioning template and the policy you created.