Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to enable TLS on MQTT client ?

Hi, all.

I'm making a mqtt client with nRF52832.

All examples of SDK 14.2 were using PSK secure.

But I want more secured connection as like MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA or MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA.

Q1: How to generate private key, private certification and CA certification ?

I used openssl in my Linux PC for that but it seems doesn't work.

Q2: How to include PEM formatted key files in nrf_tls_certificate_t structure ?

Comments in the code says "PEM format" is required.

So, I converted key file as like below. Is this right thing ?

-----BEGIN RSA PRIVATE KEY-----

MIICXAIBAAKBgQC.....................

===>

static const uint8_t private_crt{} = {

0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43, 0x45.......

};

Q3: p_ca_cert_pem can be NULL?

Is CA certificate required to make a secured connection ?