intel / intel/QAT_Engine

How to handle SSL_ERROR_WANT_ASYNC in libevent

Open
#122 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
443
Forks
137
PR merge metrics
No merged PRs in 30d

Description

I want to integrate the ASYNC ssl features of openssl into libevent so that libevent supports qat. I encountered some problems in my work and would like to ask for your help.

The implementation process is as follows:

1. SSL_CTX_set_mode(SSL_MODE_ASYNC);
2. SSL_set_mode(SSL_MODE_ASYNC);
3. after tcp connect, get clientfd
4. event_add(clientfd, EV_READ|EV_WRITE, ssl_handshake);
5. When the client is readable / writable, run ssl_handshake.

``` c
ssl_handshake()
{
SSL_do_handshake();
err = SSL_get_error();
if (err == SSL_ERROR_WANT_ASYNC)
{
event_del(clientfd, EV_READ);
event_del(clientfd, EV_WRITE);

call SSL_get_changed_async_fds() get async_fds

// Register a readable event on asyncfd to detect when the engine is ready
event_add(async_fds, READ, ssl_async_handshake);
}
}
```

6. When async_fds is readable, it means that the engine is ready. Run ssl_async_handshake, re-enable the clientfd read and write events, and continue the operation(next SSL_do_handshake)
``` c
ssl_async_handshake()
{
event_add(clientfd, EV_READ, ssl_handshake);
event_add(clientfd, EV_WRITE, ssl_handshake);
}
```

Q1. Is there a problem with my process?

Q2. During the test, SSL_do_handshake will continue to return SSL_ERROR_WANT_ASYNC multiple times (exactly 9 times) before it succeeds. Is this normal?

Q3. The processing flow of SSL_read / SSL_write returning SSL_ERROR_WANT_ASYNC is similar to that of SSL_do_handshark, but SSL_read / SSL_write never returns SSL_ERROR_WANT_ASYNC during the test, is this a normal result? How can I test the processing flow of SSL_read / SSL_write returning SSL_ERROR_WANT_ASYNC?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.