Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] unknown psk identity

Hi,

I am using paho.mqtt.cpp 1.4.1 with paho.mqtt.c 1.3.13 and getting the following error when using TLS-PSK to connect my client to mosquitto broker:
SSL Error Msg: 90840000:error:0A00045B:SSL routines:ssl3_read_bytes:tlsv1 alert unknown psk identity:..\ssl\record\rec_layer_s3.c:907:SSL alert number 115

The broker is also returning unknown psk identity:
OpenSSL Error[0]: error:0A0000DF:SSL routines::psk identity not found

I am setting the psk_handler in the paho client as follows:
        m_ssl_options = mqtt::ssl_options_builder()
        .psk_handler([&](const std::string& hint, char* identity, size_t max_identity_len, unsigned char* psk, size_t max_psk_len)
            {
                size_t ret = 0;
                const std::string psk_hint = "testing";
                std::string psk_identity = m_config.GetPSKIdentity();
                std::string psk_data = m_config.GetPSK();
                if (psk_hint == hint)
                {
                    if (psk_identity.length() <= max_identity_len)
                    {
                        identity = psk_identity.data();
                        if (psk_data.length() <= max_psk_len)
                        {
                            psk = reinterpret_cast<unsigned char*>(psk_data.data());
                            ret = psk_data.length();
                            std::cout << CurrentTimeStr() << "PSK_HINT [" << hint << "] PSK_IDENTITY [" << identity << "] PSK [" << psk << "]" << std::endl;
                        }
                    }
                }
                return ret;
            })

Are there any known issues with paho.mqtt.cpp support for TLS-PSK?
Is there anything else I need to do in my client code to configure TLS-PSK?

When I use the mosquitto_pub and mosquitto_sub test clients it works as expected.

Thanks very much for your help!


Back to the top