SMTPS MbedTLS TLS not working

Hi,

I am using Keil v5 (RTX5) with the EVBK-IMXRT1050 board.

I have successfully sent an email using the example code given through the pack installer, SMTP_client. Now I want to send a secure email, SMTPS, using the same example but adding mbedTLS. I followed the instructions given from Keil, but have not been able to get a secure email to send.
www.keil.com/.../use_secure_components.html

Below is my event recorder when trying to send out a SMTPS using mbedTLS, everything works fine until I reach line 41 where TLS should begin. The socket is closed right when TLS should begin and I am not sure why. Wireshark matched the event recorder.

If anyone has had this issue or have any tips on getting around this error, please reply. Thanks.

Event recorder:
Event, Time (sec), Component, Event Property, Value
0, 5.45808617, EvCtrl, EventRecorderInitialize, Restart Count = 3
1, 5.45812999, EvCtrl, EventRecorderStart,
2, 5.45863391, Net_SYS, InitSystem, ver=7.10.0
3, 5.45974125, Net_DHCP, InitClient, vcid=0 opt=0
4, 5.45976630, Net_DHCP, StartClient,
5, 5.45981325, Net_SMTP, InitClient, smtp
6, 5.45986813, Net_SYS, InitComplete, success
7, 5.46012398, Net_SMTP, SendMail, recipients=1
8, 5.46044442, Net_ETH, LinkDownError, no-link
9, 5.66058112, Net_ETH, LinkDownError, no-link
10, 7.66053657, Net_ETH, LinkDownError, no-link
11, 8.36051481, Net_DHCP, ClientState, state=INIT
12, 8.36055019, Net_DHCP, SendDhcpMessage, type=DHCP_DISCOVER bcast=1
13, 8.36076685, Net_DHCP, NextState, state=SELECTING
14, 8.36318817, Net_DHCP, ReceiveFrame, server=10.0.2.17 len=300
15, 8.36321537, Net_DHCP, ClientState, state=SELECTING
16, 8.36322062, Net_DHCP, DhcpOfferReceived,
17, 8.36322724, Net_DHCP, ShowServerId, server_id=10.0.2.17
18, 8.36323507, Net_DHCP, ShowOfferedIpAddress, ip=10.0.2.157
19, 8.36323565, Net_DHCP, SendDhcpMessage, type=DHCP_REQUEST bcast=1
20, 8.36334852, Net_DHCP, NextState, state=REQUESTING
21, 8.36697469, Net_DHCP, ReceiveFrame, server=10.0.2.17 len=300
22, 8.36698434, Net_DHCP, ClientState, state=REQUESTING
23, 8.36699382, Net_DHCP, DhcpAckReceived,
24, 8.36699851, Net_DHCP, ShowAssignedAddress, ip=10.0.2.157
25, 8.36705461, Net_DHCP, ShowLeaseTime, time=171072
26, 8.36705907, Net_DHCP, ShowNetMask, mask=255.255.0.0
27, 8.36706187, Net_DHCP, ShowGatewayAddress, gateway=10.0.2.2
28, 8.36707048, Net_DHCP, ShowDnsServers, pri=8.8.8.8 sec=8.8.4.4
29, 8.36707621, Net_DHCP, NextState, state=BOUND
30, 9.66583049, Net_SMTP, ConnectIp4, ip=10.0.1.2 port=587
31, 9.66751124, Net_SMTP, SocketConnected, sock=1
32, 9.66857944, Net_SMTP, ReceiveFrame, sock=1 len=58
33, 9.66860121, Net_SMTP, ServerReady,
34, 9.66878471, Net_SMTP, SendCommand, command=EHLO evkb-imxrt1050
35, 9.66962207, Net_SMTP, ReceiveFrame, sock=1 len=146
36, 9.66966114, Net_SMTP, EsmtpModeActive,
37, 9.66966166, Net_SMTP, TlsSupportIndicated,
38, 9.66977401, Net_SMTP, SendCommand, command=STARTTLS
39, 9.76064354, Net_SMTP, ReceiveFrame, sock=1 len=30
40, 9.76066607, Net_SMTP, StartTlsAccepted,
41, 9.76085824, Net_SMTP, TlsModeStarted,
42, 9.76109192, Net_SMTP, SocketClosed, sock=1
43, 9.76116411, Net_SMTP, ClientCloseSocket, sock=1
44, 9.86054282, Net_SMTP, ClientDone, cb_event=Error

Parents
  • In line 41, the SMTP client waits for the mbedTLS session to establish. This is for some reason terminated by the SMTP server. The sequence of events, that are from the Network library are fine.

    Try to send a secure email using one of your private accounts, such as Google or Yahoo. If it works, you probably have a non-standard SMTP server configuration. Then check with your SMTP server, which options in mbedTLS need to be changed. Here are the settings for use:

    Gmail:

    SMTP server: smtp.gmail.com
    Username   : <your gmail address>
    Password   : <your gmail password>
    SMTP port  : 465 (SSL)
                 587 (TLS)
                  25 (explicit TLS)
    TLS/SSL    : yes
    

    Yahoo:

    SMTP server: smtp.mail.yahoo.com
    Username   : <your yahoo email address>
    Password   : <your yahoo password>
    SMTP port  : 465 (SSL)
                  25 (explicit TLS)
    TLS/SSL    : yes
    

    The other (and more complex) way is to enable debugging in mbedTLS. However, mbedTLS uses printf style, so you will need an ITM channel that will allow you to capture debuging messages. Here are some tips:
    www.keil.com/.../network_troubleshoot.html

Reply
  • In line 41, the SMTP client waits for the mbedTLS session to establish. This is for some reason terminated by the SMTP server. The sequence of events, that are from the Network library are fine.

    Try to send a secure email using one of your private accounts, such as Google or Yahoo. If it works, you probably have a non-standard SMTP server configuration. Then check with your SMTP server, which options in mbedTLS need to be changed. Here are the settings for use:

    Gmail:

    SMTP server: smtp.gmail.com
    Username   : <your gmail address>
    Password   : <your gmail password>
    SMTP port  : 465 (SSL)
                 587 (TLS)
                  25 (explicit TLS)
    TLS/SSL    : yes
    

    Yahoo:

    SMTP server: smtp.mail.yahoo.com
    Username   : <your yahoo email address>
    Password   : <your yahoo password>
    SMTP port  : 465 (SSL)
                  25 (explicit TLS)
    TLS/SSL    : yes
    

    The other (and more complex) way is to enable debugging in mbedTLS. However, mbedTLS uses printf style, so you will need an ITM channel that will allow you to capture debuging messages. Here are some tips:
    www.keil.com/.../network_troubleshoot.html

Children
More questions in this forum