upas/fs: tls sni support for pop3/imap

This commit is contained in:
cinap_lenrek 2017-03-16 22:06:31 +01:00
parent cb1dc365c2
commit 3d052eb2ea
4 changed files with 6 additions and 5 deletions

View file

@ -216,7 +216,7 @@ char* delmessages(int, char**);
char *flagmessages(int, char**);
void digestmessage(Mailbox*, Message*);
int wraptls(int);
int wraptls(int, char*);
void eprint(char*, ...);
void iprint(char *, ...);

View file

@ -802,7 +802,7 @@ imap4dial(Imap *imap)
port = "imap";
if((imap->fd = dial(netmkaddr(imap->host, "net", port), 0, 0, 0)) < 0)
return imaperrstr(imap->host, port);
if(imap->flags & Fssl && (imap->fd = wraptls(imap->fd)) < 0){
if(imap->flags & Fssl && (imap->fd = wraptls(imap->fd, imap->host)) < 0){
err = imaperrstr(imap->host, port);
imap4disconnect(imap);
return err;

View file

@ -151,7 +151,7 @@ pop3capa(Pop *pop)
return s;
Bterm(&pop->bin);
Bterm(&pop->bout);
if((pop->fd = wraptls(pop->fd)) < 0)
if((pop->fd = wraptls(pop->fd, pop->host)) < 0)
return geterrstr();
pop->encrypted = 1;
Binit(&pop->bin, pop->fd, OREAD);
@ -237,7 +237,7 @@ pop3dial(Pop *pop)
if((pop->fd = dial(netmkaddr(pop->host, "net", pop->needssl ? "pop3s" : "pop3"), 0, 0, 0)) < 0)
return geterrstr();
if(pop->needssl && (pop->fd = wraptls(pop->fd)) < 0)
if(pop->needssl && (pop->fd = wraptls(pop->fd, pop->host)) < 0)
return geterrstr();
pop->encrypted = pop->needssl;
Binit(&pop->bin, pop->fd, OREAD);

View file

@ -4,7 +4,7 @@
#include "dat.h"
int
wraptls(int ofd)
wraptls(int ofd, char *host)
{
uchar digest[SHA1dlen];
Thumbprint *thumb;
@ -12,6 +12,7 @@ wraptls(int ofd)
int fd;
memset(&conn, 0, sizeof conn);
conn.serverName = host;
fd = tlsClient(ofd, &conn);
if(fd < 0){
close(ofd);