With this structure all the project runs properly, however when I try to use the ATECC608 the MQTT connection gives me the following messages:
I (72710) coreMQTT: Establishing a TLS session to my_URL
I (72820) esp-tls-mbedtls: Initialize the ATECC interface…
D (74340) coreMQTT: Encoded size for length 103 is 1 bytes.
D (74340) coreMQTT: CONNECT packet remaining length=103 and packet size=105.
D (74340) coreMQTT: CONNECT packet size is 105 and remaining length is 103.
D (74350) coreMQTT: sendMessageVector: Bytes Sent=12, Bytes Remaining=93
D (74360) coreMQTT: sendMessageVector: Bytes Sent=2, Bytes Remaining=91
D (74370) coreMQTT: sendMessageVector: Bytes Sent=20, Bytes Remaining=71
D (74370) coreMQTT: sendMessageVector: Bytes Sent=2, Bytes Remaining=69
D (74380) coreMQTT: sendMessageVector: Bytes Sent=69, Bytes Remaining=0
E (74480) coreMQTT: A single byte was not read from the transport: transportStatus=-1.
E (74480) coreMQTT: CONNACK recv failed with status = MQTTRecvFailed.
E (74490) coreMQTT: MQTT connection failed with status = MQTTRecvFailed.
E (74490) coreMQTT: Connection with MQTT broker failed with status 4.
I (75510) coreMQTT: Sending MQTT DISCONNECT success with status=0.
I have checked the meaning of MQTTRecvFailed: The transport receive function failed.
I suppose that the problem is related to the new certificates, but I do not know which is the problem.
I don’t register the new certificate. When I didn’t use the ATECC608, I register them with JITR and the policy is attached automatically using a lambda function and it worked.
I think this is the properly way to do because doing manually it’s not suitable for us in production phase, maybe there is another option to register them automatically.
Anyway, in order to check that this is the problem I can register one and attach the policy manually. I will do it tomorrow, today I’m out of office.
The certificate which I am trying to upload is the one that “Trust Platform Design Suite” of Microchip generates. I can’t attach it, but this tool generates a zip file with the device’s, CA’s and signer’s certificates.
So, I can’t check if the problem is related with the policy or not.
How can I upload a certificate generated by the tool of Microchip?
What output does openssl give for the cert? For example, if your cert is named device.pem, run: openssl x509 -in device.pem -text -noout. Perhaps the cert is not in PEM format?
If openssl can read the cert, then we can see if openssl can verify the cert using the CA.
Does the registration work selecting the option for using a cert not registered with AWS IoT?
As an aside, for another automatic option instead of JITR, there is JITP which requires uploading a CA cert and template, and generates Things for devices connecting with certs signed by that CA; though this doesn’t solve the immediate issue since its not working manually.
Hey @ialonsoERK, it’s been a bit since you posted this issue with your cert. I wanted to reach out and see if you were still looking for help on this or if you have figured out what your problem was?
I can’t solve my problem. Now, I try to generate a new CA and certificates in order to understand all the process. I have written a script with all the steps and at the end of these steps I have my CA registered in AWS and these files:
rootCA.pem
deviceCert.key
deviceCert.crt
I copy them into my code into:
root_cert_auth.crt
client.key
client.crt
However, when I try to open the open the connection I receive the following message: esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x2700
I think that the root_cert_auth.crt shouldn’t be my root_CA.crt. but I don’t know which certificate I have to write in that file and how to associated it with my CA.
I have also tried this Amazon root CA, anyway I have tried it again now and I receive these messages:
E (214325) coreMQTT: A single byte was not read from the transport 2: transportStatus=-1.
E (214325) coreMQTT: CONNACK recv failed with status = MQTTRecvFailed.
E (214335) coreMQTT: MQTT connection failed with status = MQTTRecvFailed.
E (214345) coreMQTT: Connection with MQTT broker failed with status 4.
If I am not wrong, this means that my CA can’t verify the devive certificate. I have checked it with the following command:
openssl verify -verbose -CAfile rootCA.pem deviceCert.crt
deviceCert.crt: OK
I can register manually my certificate into IOT core. Just in case, I copied my key and my certificate into the espressif files again, but I receive the same messages.
I attach it with a lambda function. looking fot this, I have realized that the certificate is registrating correctly in mi IOT Core. So I have to check the lambda function to attach the policy and how to create the object associated to my certificate.
The other day I said one thing wrong: I register my certificate with a lambda function but I attach the policy and I create the object with JITP and I hadn’t it created for my new CA.
Now, I have my own CA and my own certificates working. In the following days, I will try to store my keys and certificates into the ATECC608.