Arm Mbed and Pelion Device Management support forum

Trouble with mbedTLS handshake when connecting to Thingspeak, client hello returns error

I am trying to send data to thingspeak.com.
I am using mbedTLS for https, but in the handshake steps client hello is not working it returns following logs,

   Socket opened successfully.


SSL state connect : 0   . Performing the SSL/TLS handshake...../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:6571: => handshake

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:3363: client state: 0

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2417: => flush output

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2429: <= flush output

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:3363: client state: 1

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2417: => flush output

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2429: <= flush output

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0719: => write client hello

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0757: client hello, max version: [3:3]

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0766: dumping 'client hello, random bytes' (32 bytes)

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0766: 0000:  da 62 ed 2f dc 6e 08 0f 87 cd 66 a6 32 30 21 c0  .b./.n....f.20!.

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0766: 0010:  1b e2 e1 83 47 e9 b6 de 24 53 5e e3 b0 d1 39 35  ....G...$S^...95

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0819: client hello, session id len.: 0

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0820: dumping 'client hello, session id' (0 bytes)

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0887: client hello, add ciphersuite: c02c

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0887: client hello, add ciphersuite: c030

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0887: client hello, add ciphersuite: c0ad

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0887: client hello, add ciphersuite: c0af

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0887: client hello, add ciphersuite: c02b

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0887: client hello, add ciphersuite: c02f

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0887: client hello, add ciphersuite: c0ac

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0887: client hello, add ciphersuite: c0ae

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0887: client hello, add ciphersuite: 009d

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0887: client hello, add ciphersuite: c09d

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0887: client hello, add ciphersuite: c0a1

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0887: client hello, add ciphersuite: 009c

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0887: client hello, add ciphersuite: c09c

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0887: client hello, add ciphersuite: c0a0

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0920: client hello, got 15 ciphersuites

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0951: client hello, compress len.: 1

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0953: client hello, compress alg.: 0

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0072: client hello, adding server name extension: api.thingspeak.com

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0178: client hello, adding signature_algorithms extension

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0263: client hello, adding supported_elliptic_curves extension

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0328: client hello, adding supported_point_formats extension

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0544: client hello, adding extended_master_secret extension

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:0577: client hello, adding session ticket extension

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:1025: client hello, total extension length: 91

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2702: => write record

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2839: output record: msgtype = 22, version = [3:1], msglen = 166

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2842: dumping 'output record sent to network' (171 bytes)

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2842: 0000:  16 03 01 00 a6 01 00 00 a2 03 03 da 62 ed 2f dc  ............b./.

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2842: 0010:  6e 08 0f 87 cd 66 a6 32 30 21 c0 1b e2 e1 83 47  n....f.20!.....G

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2842: 0020:  e9 b6 de 24 53 5e e3 b0 d1 39 35 00 00 1e c0 2c  ...$S^...95....,

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2842: 0030:  c0 30 c0 ad c0 af c0 2b c0 2f c0 ac c0 ae 00 9d  .0.....+./......

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2842: 0040:  c0 9d c0 a1 00 9c c0 9c c0 a0 00 ff 01 00 00 5b  ...............[

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2842: 0050:  00 00 00 17 00 15 00 00 12 61 70 69 2e 74 68 69  .........api.thi

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2842: 0060:  6e 67 73 70 65 61 6b 2e 63 6f 6d 00 0d 00 12 00  ngspeak.com.....

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2842: 0070:  10 06 03 06 01 05 03 05 01 04 03 04 01 03 03 03  ................

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2842: 0080:  01 00 0a 00 18 00 16 00 19 00 1c 00 18 00 1b 00  ................

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2842: 0090:  17 00 16 00 1a 00 15 00 14 00 13 00 12 00 0b 00  ................

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2842: 00a0:  02 01 00 00 17 00 00 00 23 00 00                 ........#..

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2417: => flush output

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2436: message length: 171, out_left: 171


../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2442: ssl->f_send() returned -30848 (-0x7880)

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2847: mbedtls_ssl_flush_output() returned -30848 (-0x7880)

../Middlewares/Third_Party/mbedTLS/library/ssl_cli.c:1047: mbedtls_ssl_write_record() returned -30848 (-0x7880)

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:6582: <= handshake

 failed
  ! mbedtls_ssl_handshake returned -0x7880


Failed closing the socket.
../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:7359: => free

../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:7424: <= free

I am able to use HTTP get and send data, but the problem comes in the handshake when I use mbedTLS.
whether I can send raw hex values using CIPSEND? or I had to use any other characters?

Hi Ajmal,

From the log, it says mbedtls_ssl_handshake returned -0x7880, which indicates “The peer notified us that the connection is going to be closed”. You should check the value you sent to server.

Regards,
Desmond

1 Like

Thanks for your valuable reply.
I already finished the handshake process successfully.