/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "istream.h"
#include "ostream.h"
#include "iostream-ssl.h"
#include "master-service.h"
#include "master-service-ssl.h"
#include "smtp-syntax.h"
#include "smtp-server-private.h"
/* STARTTLS command (RFC 3207) */
{
int ret;
return -1;
} else if (smtp_server_connection_ssl_init(conn) < 0) {
"SSL Initialization failed");
return -1;
}
/* RFC 3207, Section 4.2:
Upon completion of the TLS handshake, the SMTP protocol is reset to
the initial state (the state in SMTP after a server issues a 220
service ready greeting). The server MUST discard any knowledge
obtained from the client, such as the argument to the EHLO command,
which was not obtained from the TLS negotiation itself.
*/
return 0;
}
{
int ret;
return 1;
if (ret > 0) {
if (cmd_starttls_start(conn) < 0)
return -1;
}
return 1;
}
{
int ret;
return;
/* only one valid success status for STARTTLS command */
/* uncork */
/* flush */
return;
} else if (ret == 0) {
/* the buffer has to be flushed */
conn);
} else {
}
}
}
{
int ret;
else
ret = 1;
if (ret <= 0) {
/* command is waiting for external event or it failed */
return;
}
if (!smtp_server_command_is_replied(command)) {
220, "2.0.0", "Begin TLS negotiation now.");
}
}
const char *params)
{
if (conn->ssl_secured) {
502, "5.5.1", "TLS is already active.");
return;
} else if ((capabilities & SMTP_CAPABILITY_STARTTLS) == 0) {
502, "5.5.1", "TLS support is not enabled.");
return;
}
/* "STARTTLS" CRLF */
if (*params != '\0') {
501, "5.5.4", "Invalid parameters");
return;
}
}