aboutsummaryrefslogtreecommitdiff
path: root/test/ssltestlib.c
diff options
context:
space:
mode:
authorBenjamin Kaduk <bkaduk@akamai.com>2017-02-13 15:10:54 -0600
committerRichard Levitte <levitte@openssl.org>2017-02-23 19:40:27 +0100
commit8e2236eff8e38109a57347c8ad795040b380c936 (patch)
tree22f926a2a915e28f23f673d75e342aa829093d65 /test/ssltestlib.c
parent694c9180d7f082b896692048052413fc5dc4e467 (diff)
downloadopenssl-8e2236eff8e38109a57347c8ad795040b380c936.zip
openssl-8e2236eff8e38109a57347c8ad795040b380c936.tar.gz
openssl-8e2236eff8e38109a57347c8ad795040b380c936.tar.bz2
Let test handshakes stop on certain errors
Certain callback APIs allow the callback to request async processing by trickling a particular error value up the stack to the application as an error return from the handshake function. In those cases, SSL_want() returns a code specific to the type of async processing needed. The create_ssl_connection() helper function for the tests is very helpful for several things, including creating API tests. However, it does not currently let us test the async processing functionality of these callback interfaces, because the special SSL error codes are treated as generic errors and the helper continues to loop until it reaches its maximum iteration count. Add a new parameter, 'want', that indicates an expected/desired special SSL error code, so that the helper will terminate when either side reports that error, giving control back to the calling function and allowing the test to proceed. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2279)
Diffstat (limited to 'test/ssltestlib.c')
-rw-r--r--test/ssltestlib.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/test/ssltestlib.c b/test/ssltestlib.c
index 8a4dd49..64aa916 100644
--- a/test/ssltestlib.c
+++ b/test/ssltestlib.c
@@ -641,7 +641,7 @@ int create_ssl_objects(SSL_CTX *serverctx, SSL_CTX *clientctx, SSL **sssl,
return 0;
}
-int create_ssl_connection(SSL *serverssl, SSL *clientssl)
+int create_ssl_connection(SSL *serverssl, SSL *clientssl, int want)
{
int retc = -1, rets = -1, err, abortctr = 0;
int clienterr = 0, servererr = 0;
@@ -660,6 +660,8 @@ int create_ssl_connection(SSL *serverssl, SSL *clientssl)
printf("SSL_connect() failed %d, %d\n", retc, err);
clienterr = 1;
}
+ if (want != SSL_ERROR_NONE && err == want)
+ return 0;
err = SSL_ERROR_WANT_WRITE;
while (!servererr && rets <= 0 && err == SSL_ERROR_WANT_WRITE) {
@@ -672,6 +674,8 @@ int create_ssl_connection(SSL *serverssl, SSL *clientssl)
printf("SSL_accept() failed %d, %d\n", rets, err);
servererr = 1;
}
+ if (want != SSL_ERROR_NONE && err == want)
+ return 0;
if (clienterr && servererr)
return 0;
if (++abortctr == MAXLOOPS) {