drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

delayed SSL handshakes for SMTP

ihmc3jn09hk opened this issue · comments

@an-tao Hi, I am trying to develop a SMTP client with trantor's TCPClient. A delayed SSL handshake is needed for such communicatoin. I am encounting an issue on the SSL handshake part. As long as the transfer from TCP to SSL handshake is needed for authentication, the SMTP server will reject the connection. I am using the function from TCPClient, e.g. "tcpClientPtr_->enableSSL();" which does not work for such connection. The workflow is as following,

  1. Initiate TCP client --> server (OK)
  2. Server --> client (OK)
  3. EHLO client --> server (OK)
  4. Server --> client (OK) /Server invites an SSL connection/
  5. SSL client --> server (Failed) /called tcpClientPtr_->enableSSL(); and send information/

My guess would be "enableSSL()" does not actually perform a replacement from the TCP to SSL connection immediately. If not so, how should I perform an upgrade connection at that instant ?

@ihmc3jn09hk Hi, Currently, an SSL connection performs an SSL handshake before any other transmissions, so I have to add some new methods to Trantor to implement a delayed SSL handshake. I'll do this, thanks.

@an-tao Cool thanks. I am looking at it as well. Possible reference here.

@ihmc3jn09hk , I made a new PR to trantor for this issue, please check, thx!

@an-tao Thats quick response. I am still studying trantor, lolz. I will test it sometime soon.

@an-tao Good news, the code for delay SSL is working fine for sending email with SMTP. I modified some of the code in drogon which hopefully you will think is appropreate. please check the PR.

In order to test and use it, I have made a SMTP-Mail plugin with the Drogon framework. It is working and feel free to use the example in the wiki for the plugins tutorial if you wish.

image

  • btw, I am going to new an issue for http/2 and http/3 (http/2 + quic) functionality enhancement.

@an-tao The PR is reporting error. The following is part of the log which related to trantor. I did not modify trantor in this PR and it's dead at something unrelated to the project ? Just for noticing the issue should not be related to the PR.
opt/src/get_version.sh: not found

...
[2020-02-14 17:35:54] [build] [ 12%] Building CXX object trantor/CMakeFiles/trantor.dir/trantor/net/inner/TcpConnectionImpl.cc.o
[2020-02-14 17:35:58] [build] [ 12%] Building CXX object trantor/CMakeFiles/trantor.dir/trantor/net/inner/Timer.cc.o
[2020-02-14 17:36:00] [build] [ 13%] Building CXX object trantor/CMakeFiles/trantor.dir/trantor/net/inner/TimerQueue.cc.o
[2020-02-14 17:36:03] [build] [ 14%] Building CXX object trantor/CMakeFiles/trantor.dir/trantor/net/inner/poller/EpollPoller.cc.o
[2020-02-14 17:36:06] [build] [ 14%] Building CXX object trantor/CMakeFiles/trantor.dir/trantor/net/inner/poller/KQueue.cc.o
[2020-02-14 17:36:08] [build] [ 15%] Building CXX object trantor/CMakeFiles/trantor.dir/trantor/net/ssl/SSLConnection.cc.o
[2020-02-14 17:36:11] [build] [ 15%] Building CXX object trantor/CMakeFiles/trantor.dir/trantor/net/inner/AresResolver.cc.o
[2020-02-14 17:36:14] [build] [ 16%] Linking CXX static library libtrantor.a
[2020-02-14 17:36:14] [build] [ 16%] Built target trantor
[2020-02-14 17:36:15] [build] Scanning dependencies of target makeVersion
[2020-02-14 17:36:15] [build] /bin/sh: 1: /opt/src/get_version.sh: not found
[2020-02-14 17:36:15] [build] make[2]: *** [CMakeFiles/makeVersion.dir/build.make:57: makeVersion] Error 127
[2020-02-14 17:36:15] [build] make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/makeVersion.dir/all] Error 2
[2020-02-14 17:36:15] [build] make: *** [Makefile:130: all] Error 2
[2020-02-14 17:36:15] [build] + '[' -f setup.py ']'
[2020-02-14 17:36:15] [build] + echo 'Semmle autobuild: no supported build