imapc->state = newstate;
}
+static CURLcode imap_state_starttls(struct connectdata *conn)
+{
+ CURLcode result = CURLE_OK;
+ const char *str = getcmdid(conn);
+
+ /* Send the STARTTLS command */
+ result = imap_sendf(conn, str, "%s STARTTLS", str);
+
+ if(!result)
+ state(conn, IMAP_STARTTLS);
+
+ return result;
+}
+
static CURLcode imap_state_capability(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
if(data->set.use_ssl && !conn->ssl[FIRSTSOCKET].use) {
/* We don't have a SSL/TLS connection yet, but SSL is requested. Switch
to TLS connection now */
- const char *str = getcmdid(conn);
- result = imap_sendf(conn, str, "%s STARTTLS", str);
- if(!result)
- state(conn, IMAP_STARTTLS);
+ result = imap_state_starttls(conn);
}
else
result = imap_state_capability(conn);
pop3c->state = newstate;
}
+static CURLcode pop3_state_starttls(struct connectdata *conn)
+{
+ CURLcode result = CURLE_OK;
+
+ /* Send the STLS command */
+ result = Curl_pp_sendf(&conn->proto.pop3c.pp, "STLS");
+
+ if(!result)
+ state(conn, POP3_STARTTLS);
+
+ return result;
+}
+
static CURLcode pop3_state_capa(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct pop3_conn *pop3c = &conn->proto.pop3c;
(void)instate; /* no use for this yet */
if(data->set.use_ssl && !conn->ssl[FIRSTSOCKET].use) {
/* We don't have a SSL/TLS connection yet, but SSL is requested. Switch
to TLS connection now */
- result = Curl_pp_sendf(&pop3c->pp, "STLS");
- if(!result)
- state(conn, POP3_STARTTLS);
+ result = pop3_state_starttls(conn);
}
else
result = pop3_state_capa(conn);
return CURLE_OK;
}
+static CURLcode smtp_state_starttls(struct connectdata *conn)
+{
+ CURLcode result = CURLE_OK;
+
+ /* Send the STARTTLS command */
+ result = Curl_pp_sendf(&conn->proto.smtpc.pp, "STARTTLS");
+
+ if(!result)
+ state(conn, SMTP_STARTTLS);
+
+ return result;
+}
+
static CURLcode smtp_authenticate(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
else if(data->set.use_ssl && !conn->ssl[FIRSTSOCKET].use) {
/* We don't have a SSL/TLS connection yet, but SSL is requested. Switch
to TLS connection now */
- result = Curl_pp_sendf(&conn->proto.smtpc.pp, "STARTTLS");
- if(!result)
- state(conn, SMTP_STARTTLS);
+ result = smtp_state_starttls(conn);
}
else
result = smtp_authenticate(conn);