Minor fix to SSL authentication.

This commit is contained in:
Markus Makela
2015-06-09 02:56:55 +03:00
parent 1c36cfb285
commit 06c5da7b17
2 changed files with 20 additions and 12 deletions

View File

@ -1055,7 +1055,7 @@ int dcb_read_SSL(
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [dcb_read] Read %d bytes from dcb %p in state %s "
"%lu [dcb_read_SSL] Read %d bytes from dcb %p in state %s "
"fd %d.",
pthread_self(),
n,
@ -2800,7 +2800,7 @@ int dcb_create_SSL(DCB* dcb)
if((dcb->ssl = SSL_new(dcb->service->ctx)) == NULL)
{
skygw_log_write(LE,"Error: Failed to initialize SSL connection.");
skygw_log_write(LE,"Error: Failed to initialize SSL for connection.");
return -1;
}
@ -2828,16 +2828,10 @@ int dcb_accept_SSL(DCB* dcb)
int rval = 0,ssl_rval,errnum = 0,fd,b = 0;
char errbuf[140];
fd = dcb->fd;
ioctl(fd,FIONREAD,&b);
#ifdef SS_DEBUG
skygw_log_write(LD,"[dcb_accept_SSL] fd %d bytes: %d",fd,b);
#endif
while(b > 0 && rval != -1)
do
{
ssl_rval = SSL_accept(dcb->ssl);
#ifdef SS_DEBUG
skygw_log_write(LD,"[dcb_accept_SSL] SSL_accept returned %d.",ssl_rval);
#endif
switch(ssl_rval)
{
case 0:
@ -2889,9 +2883,10 @@ int dcb_accept_SSL(DCB* dcb)
ioctl(fd,FIONREAD,&b);
#ifdef SS_DEBUG
skygw_log_write_flush(LD,"[dcb_accept_SSL] fd %d: %d bytes",fd,b);
skygw_log_write_flush(LD,"[dcb_accept_SSL] SSL error: %d",errnum);
skygw_log_write(LD,"[dcb_accept_SSL] SSL_accept returned %d, SSL error: %d",ssl_rval,errnum);
#endif
}
}while(b > 0 && rval != -1);
return rval;
}

View File

@ -668,7 +668,18 @@ int gw_read_client_event(
return 0;
break;
case 1:
{
int b = 0;
ioctl(dcb->fd,FIONREAD,&b);
if(b == 0)
{
skygw_log_write(LD,
"[gw_read_client_event] No data in socket after SSL auth");
return 0;
}
break;
}
case -1:
return 1;
break;
@ -1897,8 +1908,10 @@ int do_ssl_accept(MySQLProtocol* protocol)
if(dcb->ssl == NULL)
{
if(dcb_create_SSL(dcb) != 0)
{
return -1;
}
}
rval = dcb_accept_SSL(dcb);