I'm using paho.mqtt.c to connect in a "Self signed certificates" way to a MQTT broker. I have 3 files I use:
- CAfile.pem (CERTIFICATE)
- PrivateKey.pem (PRIVATE KEY)
- Certifcate.pem.crt (CERTIFICATE)
When CAfile.pem contin the last certificate in the chain.
When connecting using the below I get a "Verify return code: 0 (ok)":
openssl s_client -connect 1234.iot.eu-west-1.amazonaws.com:8883
-cert Certifcate.pem.crt
-key PrivateKey.pem
-CAfile /etc/ssl/certs/ca-certificates.crt #!!!!
When connecting using the below I get a "Verify return code: 20 (unable to get local issuer certificate)":
openssl s_client -connect 1234.iot.eu-west-1.amazonaws.com:8883
-cert Certifcate.pem.crt
-key PrivateKey.pem
-CAfile CAfile.pem #!!!!
I found out that the reason for the "Verify return code: 20..." is that Starfield Class 2 (that are in my ca-certificates.crt) is missing.
When I concat Starfield Class 2 to my 'CAfile.pem' it works.
Why the failure? How do I resolve it?
-CAfile
. You say in your question that it works once you have added the missing certificate to the trust store which kind of implies that it wasn't in there before. – Steffen Ullrich Dec 13 '18 at 5:32ca-certificates.crt
and succeeds withCAfile.pem
. Please fix your question to reflect the reality. Also, add what is exactly included inCAfile.pem
since currently it is just the file you got without information about its contents. – Steffen Ullrich Dec 13 '18 at 5:41