mirror of
https://github.com/espressif/openthread.git
synced 2026-08-25 19:59:51 +00:00
[dtls] fix when SSL Server is enabled (#4024)
A call to `mbedtls_ssl_set_client_transport_id()` is necessary when using the SSL Server module. This commit ensures a call to the aforementioned function when using CoAP Secure with PSK cipher suite.
This commit is contained in:
@@ -200,7 +200,7 @@ void Dtls::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageI
|
||||
break;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_ENABLE_BORDER_AGENT || OPENTHREAD_ENABLE_COMMISSIONER
|
||||
#ifdef MBEDTLS_SSL_SRV_C
|
||||
if (mState == MeshCoP::Dtls::kStateConnecting)
|
||||
{
|
||||
SetClientId(mPeerAddress.GetPeerAddr().mFields.m8, sizeof(mPeerAddress.GetPeerAddr().mFields));
|
||||
@@ -289,7 +289,7 @@ otError Dtls::Setup(bool aClient)
|
||||
mbedtls_ssl_conf_handshake_timeout(&mConf, 8000, 60000);
|
||||
mbedtls_ssl_conf_dbg(&mConf, HandleMbedtlsDebug, this);
|
||||
|
||||
#if OPENTHREAD_ENABLE_BORDER_AGENT || OPENTHREAD_ENABLE_COMMISSIONER || OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#ifdef MBEDTLS_SSL_SRV_C
|
||||
if (!aClient)
|
||||
{
|
||||
mbedtls_ssl_cookie_init(&mCookieCtx);
|
||||
@@ -299,7 +299,7 @@ otError Dtls::Setup(bool aClient)
|
||||
|
||||
mbedtls_ssl_conf_dtls_cookies(&mConf, mbedtls_ssl_cookie_write, mbedtls_ssl_cookie_check, &mCookieCtx);
|
||||
}
|
||||
#endif // OPENTHREAD_ENABLE_BORDER_AGENT || OPENTHREAD_ENABLE_COMMISSIONER || OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
#endif
|
||||
|
||||
rval = mbedtls_ssl_setup(&mSsl, &mConf);
|
||||
VerifyOrExit(rval == 0);
|
||||
@@ -537,13 +537,13 @@ exit:
|
||||
#endif // MBEDTLS_BASE64_C
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
|
||||
#if OPENTHREAD_ENABLE_BORDER_AGENT || OPENTHREAD_ENABLE_COMMISSIONER
|
||||
#ifdef MBEDTLS_SSL_SRV_C
|
||||
otError Dtls::SetClientId(const uint8_t *aClientId, uint8_t aLength)
|
||||
{
|
||||
int rval = mbedtls_ssl_set_client_transport_id(&mSsl, aClientId, aLength);
|
||||
return Crypto::MbedTls::MapError(rval);
|
||||
}
|
||||
#endif // OPENTHREAD_ENABLE_BORDER_AGENT || OPENTHREAD_ENABLE_COMMISSIONER
|
||||
#endif
|
||||
|
||||
otError Dtls::Send(Message &aMessage, uint16_t aLength)
|
||||
{
|
||||
|
||||
@@ -335,7 +335,7 @@ public:
|
||||
void SetSslAuthMode(bool aVerifyPeerCertificate);
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
|
||||
|
||||
#if OPENTHREAD_ENABLE_BORDER_AGENT || OPENTHREAD_ENABLE_COMMISSIONER
|
||||
#ifdef MBEDTLS_SSL_SRV_C
|
||||
/**
|
||||
* This method sets the Client ID used for generating the Hello Cookie.
|
||||
*
|
||||
@@ -346,7 +346,7 @@ public:
|
||||
*
|
||||
*/
|
||||
otError SetClientId(const uint8_t *aClientId, uint8_t aLength);
|
||||
#endif // OPENTHREAD_ENABLE_BORDER_AGENT || OPENTHREAD_ENABLE_COMMISSIONER
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This method sends data within the DTLS session.
|
||||
|
||||
Reference in New Issue
Block a user