Skip to content

Commit

Permalink
Fix for CONC-180
Browse files Browse the repository at this point in the history
In case handshake ended with Errorcode SEC_E_INTERNAL_ERROR we check
LastErrorCode (if it was set) and return system errormessage. For
timeout during SSL handshake we return the following error message:

ERROR 2026 (HY000): SSL connection error: A connection attempt failed
because the connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to respond.
  • Loading branch information
9EOR9 committed May 15, 2016
1 parent 9d51d5e commit 07877e6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions libmariadb/secure/ma_schannel.c
Expand Up @@ -26,6 +26,7 @@
#define MAX_SSL_ERR_LEN 100

#define SCHANNEL_PAYLOAD(A) (A).cbMaximumMessage - (A).cbHeader - (A).cbTrailer
void ma_schannel_set_win_error(MARIADB_PVIO *pvio);

/* {{{ void ma_schannel_set_sec_error */
void ma_schannel_set_sec_error(MARIADB_PVIO *pvio, DWORD ErrorNo)
Expand Down Expand Up @@ -70,6 +71,12 @@ void ma_schannel_set_sec_error(MARIADB_PVIO *pvio, DWORD ErrorNo)
break;
case SEC_E_OK:
break;
case SEC_E_INTERNAL_ERROR:
if (GetLastError())
ma_schannel_set_win_error(pvio);
else
pvio->set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN, "The Local Security Authority cannot be contacted");
break;
default:
__debugbreak();
pvio->set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN, "Unknown SSL error (0x%x)", ErrorNo);
Expand Down Expand Up @@ -511,7 +518,6 @@ SECURITY_STATUS ma_schannel_handshake_loop(MARIADB_PVIO *pvio, my_bool InitialRe
OutBuffers.pvBuffer = NULL;
}
}

/* check if we need to read more data */
switch (rc) {
case SEC_E_INCOMPLETE_MESSAGE:
Expand Down Expand Up @@ -548,7 +554,6 @@ SECURITY_STATUS ma_schannel_handshake_loop(MARIADB_PVIO *pvio, my_bool InitialRe
default:
if (FAILED(rc))
{
ma_schannel_set_sec_error(pvio, rc);
goto loopend;
}
break;
Expand All @@ -563,8 +568,11 @@ SECURITY_STATUS ma_schannel_handshake_loop(MARIADB_PVIO *pvio, my_bool InitialRe
cbIoBuffer = 0;
}
loopend:
if (FAILED(rc))
if (FAILED(rc))
{
ma_schannel_set_sec_error(pvio, rc);
DeleteSecurityContext(&sctx->ctxt);
}
LocalFree(IoBuffer);

return rc;
Expand Down

0 comments on commit 07877e6

Please sign in to comment.