StartSSL混淆后的C ++ SSL SMTP服务器协议

时间:2016-01-06 21:49:43

标签: c++ openssl smtp smtp-auth

我需要用C ++编写自定义SMTP服务,要求它需要支持SSL,我一直在查看两个SMTP RFC 2821RFC 5321,但我不能弄清楚消息排序。我从邮件客户端获得以下内容。

从邮件客户端收到的邮件:

[Received from client] EHLO PAULMORRISSAB5A
[Received from client] STARTTLS
[Received from client] ▬▬☺

最后一条消息是什么,服务器应该回复什么?

1 个答案:

答案 0 :(得分:0)

使用STARTTLS(无需身份验证)与smtp服务器建立SSL连接:

curl "http://localhost:2113/projection/$by_category/command/enable" -X POST -H "Content-Length: 0" -H "Authorization: Basic YWRtaW46Y2hhbmdlaXQ="
  

例如在c ++中的Openssl部分(你不需要发送这3行)

S: <waits for connection on TCP port 25>
C: <opens connection>
S: 220 mail.imc.org SMTP service ready
C: EHLO mail.example.com\r\n
S: 250-mail.imc.org offers a warm hug of welcome
S: 250-8BITMIME
S: 250-STARTTLS
S: 250 DSN
C: STARTTLS\r\n
S: 220 Go ahead
    C: <starts TLS negotiation>
    C & S: <negotiate a TLS session>
    C & S: <check result of negotiation>

这里简单的c ++ ssl smtp客户端: https://github.com/breakermind/SslSMTPClient