Development OS: Ubuntu 16.04
Toolchain: gnuarmemb
Hardware: nRF9160 DK, modem firmware 1.0.1
EDIT: board setting in build system is nrf9160_pca10090ns
Software: nRF SDK master and v1.0.0
-----
I am trying to modify the mqtt_simple example to use TLS-PSK with a 64-byte PSK, but am only having luck using certificates. I have reviewed other DevZone questions about PSK and MQTT, but unfortunately the issue I am having seems unrelated to those.
The nrf9160 is able to successfully store a test PSK of 64Bytes and corresponding client ID using nrf_inbuilt_key
library. I confirmed that the same client_id and psk could successfully establish a TLS session with the broker by running:
gnutls-cli <broker ip> -p 8883 --pskusername=<client id> --pskkey=<key> --priority=SECURE128:SECURE256:+PSK
I am testing mostly with the master branch of the NRF SDK as v1.0.0 has a multiple definition problem when I enable mbedTLS for PSK ciphersuites.
The client is able to bring up the LTE Link and establish a TCP connection to the broker without issue, but fails in the TLS handshake when using PSKs. (Using certs with the same broker on a different port successfully establishes an MQTT connection). The failure occurs during the process of the mqtt_connect() function.
I captured several packets during the process of the client attempting to connect and inspection with wireshark indicates that the server issues a fatal "unexpected message" alert after the client sends a "Client Key Exchange, ChangeCipherSpec" message. The cipher agreed upon in "Client Hello -> Server Hello, Server Hello Done" sequence was TLS_PSK_WITH_AES_256_CBC_SHA (enabled on the nrf9160 using menuconfig path (Top) → Zephyr Kernel → Modules → TLS configuration → Ciphersuite configuration).
Does anyone have any advice on how to resolve or debug this connection problem? I'm sure that it's just a configuration or API that I'm missing, but after tons of blind changes in menuconfig I need another set of eyes. I'll happily provide any additional information, but the packet captures contain some sensitive info so I cannot publicly provide those. Attached please find my test code, CMakeLists.txt, and prj.conf. Thanks for any assistance you can provide.