forked from wolfSSL/wolfssl
Merge pull request #4923 from miyazakh/set_bio
Set bio read/write flag obviously
This commit is contained in:
@ -17568,7 +17568,12 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
|
|||||||
wolfSSL_BIO_free(ssl->biord);
|
wolfSSL_BIO_free(ssl->biord);
|
||||||
ssl->biord = NULL;
|
ssl->biord = NULL;
|
||||||
}
|
}
|
||||||
|
/* set flag obviously */
|
||||||
|
if (rd && !(rd->flags & WOLFSSL_BIO_FLAG_READ))
|
||||||
|
rd->flags |= WOLFSSL_BIO_FLAG_READ;
|
||||||
|
if (wr && !(wr->flags & WOLFSSL_BIO_FLAG_WRITE))
|
||||||
|
wr->flags |= WOLFSSL_BIO_FLAG_WRITE;
|
||||||
|
|
||||||
ssl->biord = rd;
|
ssl->biord = rd;
|
||||||
ssl->biowr = wr;
|
ssl->biowr = wr;
|
||||||
|
|
||||||
|
39
tests/api.c
39
tests/api.c
@ -38776,6 +38776,44 @@ static void test_wolfSSL_BIO_connect(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void test_wolfSSL_BIO_Qt_usecase()
|
||||||
|
{
|
||||||
|
#if !defined(NO_BIO) && defined(OPENSSL_EXTRA) && !defined(NO_WOLFSSL_CLIENT)
|
||||||
|
|
||||||
|
printf(testingFmt, "test_wolfSSL_BIO_Qt_usecase()");
|
||||||
|
|
||||||
|
SSL_CTX* ctx;
|
||||||
|
SSL *ssl;
|
||||||
|
BIO *readBio;
|
||||||
|
BIO *writeBio;
|
||||||
|
int ret, err;
|
||||||
|
|
||||||
|
AssertNotNull(ctx = SSL_CTX_new(SSLv23_method()));
|
||||||
|
AssertNotNull(ssl = SSL_new(ctx));
|
||||||
|
|
||||||
|
AssertNotNull(readBio = BIO_new(BIO_s_mem()));
|
||||||
|
AssertNotNull(writeBio = BIO_new(BIO_s_mem()));
|
||||||
|
/* Qt reads data from write-bio,
|
||||||
|
* then writes the read data into plain packet.
|
||||||
|
* Qt reads data from plain packet,
|
||||||
|
* then writes the read data into read-bio.
|
||||||
|
*/
|
||||||
|
SSL_set_bio(ssl, readBio, writeBio);
|
||||||
|
AssertIntEQ(ret = SSL_connect(ssl), WOLFSSL_FATAL_ERROR);
|
||||||
|
err = SSL_get_error(ssl, ret);
|
||||||
|
/* in this use case, should return WANT READ
|
||||||
|
* so that Qt will read the data from plain packet for next state.
|
||||||
|
*/
|
||||||
|
AssertIntEQ(err, SSL_ERROR_WANT_READ);
|
||||||
|
|
||||||
|
SSL_free(ssl);
|
||||||
|
SSL_CTX_free(ctx);
|
||||||
|
|
||||||
|
printf(resultFmt, passed);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(OPENSSL_ALL) && defined(HAVE_IO_TESTS_DEPENDENCIES) && defined(HAVE_HTTP_CLIENT)
|
#if defined(OPENSSL_ALL) && defined(HAVE_IO_TESTS_DEPENDENCIES) && defined(HAVE_HTTP_CLIENT)
|
||||||
static THREAD_RETURN WOLFSSL_THREAD test_wolfSSL_BIO_accept_client(void* args)
|
static THREAD_RETURN WOLFSSL_THREAD test_wolfSSL_BIO_accept_client(void* args)
|
||||||
{
|
{
|
||||||
@ -52685,6 +52723,7 @@ void ApiTest(void)
|
|||||||
test_wolfSSL_BIO_printf();
|
test_wolfSSL_BIO_printf();
|
||||||
test_wolfSSL_BIO_f_md();
|
test_wolfSSL_BIO_f_md();
|
||||||
test_wolfSSL_BIO_up_ref();
|
test_wolfSSL_BIO_up_ref();
|
||||||
|
test_wolfSSL_BIO_Qt_usecase();
|
||||||
#endif
|
#endif
|
||||||
test_wolfSSL_cert_cb();
|
test_wolfSSL_cert_cb();
|
||||||
test_wolfSSL_SESSION();
|
test_wolfSSL_SESSION();
|
||||||
|
Reference in New Issue
Block a user