-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Closed
prchander/openssl
#3Labels
branch: 1.1.1Applies to OpenSSL_1_1_1-stable branch (EOL)Applies to OpenSSL_1_1_1-stable branch (EOL)branch: masterApplies to master branchApplies to master branchseverity: importantImportant bugs affecting a released versionImportant bugs affecting a released versiontriaged: bugThe issue/pr is/fixes a bugThe issue/pr is/fixes a bug
Description
In TLS servers where asynchronous reads and writes may be flowing concurrently(non-block socket) , OpenSSL's TLS 1.3 can't support call SSL_key_update between SSL_ERROR_WANT_WRITE return by SSL_write and next SSL_write or SSL_read.
it will fail with the following error:
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_WRITE_BYTES,SSL_R_BAD_LENGTH);
I have seen similar cases #8677, but our case is that call SSL_key_update while writes are pending(no-blocking socket).
may be our using logic is wrong?
Is there any documentation that supports this issue?
this is test case:
ssl = SSL_new(Context);
new_sd = create_socket();
if (ioctl(iSd, FIONBIO, &nonBlock) == SOCKET_ERROR)
{
printf("ioctl() failed with error %d\n", ipsi_get_last_socket_error());
return;
}
ret =SSL_setSockId(ssl, (SEC_SOCK)iSd);
while(1){
err = SSL_accept(ssl); //connect to the server
if (err == 1)
{
break;
}
}
// step1 :Write a large message on the server,until SSL_write return -1 with SSL_ERROR_WANT_WRITE
while(1)
{
ret = SSL_write(ssl, buf_write, sizeof(buf_write));
if(ret == -1 && SSL_get_error(ssl, ret) == SSL_ERROR_WANT_WRITE)
{
printf("SSL_ERROR_WANT_WRITE exit\n");
break;
}
}
//step2: server call SSL_key_update
ret = SSL_key_update(ssl, SSL_KEY_UPDATE_NOT_REQUESTED); //SSL_KEY_UPDATE_REQUESTED
TEST_ASSERT(ret == TEST_SSL_SUCCESS,"SSL_key_update");
//step3: do SSL_write again,it will fail and return error :SSL_R_BAD_LENGTH
ret = SSL_write(ssl, buf_write, sizeof(buf_write));
TEST_ASSERT(ret != -1,"SSL_write fail");
err = SSL_get_error(ssl, ret);
printf("last write err=%d\n",err);
printf("\nret: %d, SSL_getLastError: %d\n",ret, ERR_GET_REASON(ERR_peek_error())); //**SSL_R_BAD_LENGTH**
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
branch: 1.1.1Applies to OpenSSL_1_1_1-stable branch (EOL)Applies to OpenSSL_1_1_1-stable branch (EOL)branch: masterApplies to master branchApplies to master branchseverity: importantImportant bugs affecting a released versionImportant bugs affecting a released versiontriaged: bugThe issue/pr is/fixes a bugThe issue/pr is/fixes a bug