252 |
|
ssl_handshake(int fd, struct Client *client_p) |
253 |
|
{ |
254 |
|
X509 *cert = NULL; |
255 |
< |
int ret = SSL_accept(client_p->localClient->fd.ssl); |
255 |
> |
int ret = 0; |
256 |
> |
|
257 |
> |
if ((ret = SSL_accept(client_p->localClient->fd.ssl)) <= 0) |
258 |
> |
{ |
259 |
> |
switch (SSL_get_error(client_p->localClient->fd.ssl, ret)) |
260 |
> |
{ |
261 |
> |
case SSL_ERROR_WANT_WRITE: |
262 |
> |
comm_setselect(&client_p->localClient->fd, COMM_SELECT_WRITE, |
263 |
> |
(PF *) ssl_handshake, client_p, 0); |
264 |
> |
return; |
265 |
> |
|
266 |
> |
case SSL_ERROR_WANT_READ: |
267 |
> |
comm_setselect(&client_p->localClient->fd, COMM_SELECT_READ, |
268 |
> |
(PF *) ssl_handshake, client_p, 0); |
269 |
> |
return; |
270 |
> |
|
271 |
> |
default: |
272 |
> |
exit_client(client_p, client_p, "Error during SSL handshake"); |
273 |
> |
return; |
274 |
> |
} |
275 |
> |
} |
276 |
|
|
277 |
|
if ((cert = SSL_get_peer_certificate(client_p->localClient->fd.ssl))) |
278 |
|
{ |
299 |
|
X509_free(cert); |
300 |
|
} |
301 |
|
|
282 |
– |
if (ret <= 0) |
283 |
– |
{ |
284 |
– |
switch (SSL_get_error(client_p->localClient->fd.ssl, ret)) |
285 |
– |
{ |
286 |
– |
case SSL_ERROR_WANT_WRITE: |
287 |
– |
comm_setselect(&client_p->localClient->fd, COMM_SELECT_WRITE, |
288 |
– |
(PF *) ssl_handshake, client_p, 0); |
289 |
– |
return; |
290 |
– |
|
291 |
– |
case SSL_ERROR_WANT_READ: |
292 |
– |
comm_setselect(&client_p->localClient->fd, COMM_SELECT_READ, |
293 |
– |
(PF *) ssl_handshake, client_p, 0); |
294 |
– |
return; |
295 |
– |
|
296 |
– |
default: |
297 |
– |
exit_client(client_p, client_p, "Error during SSL handshake"); |
298 |
– |
return; |
299 |
– |
} |
300 |
– |
} |
301 |
– |
|
302 |
|
start_auth(client_p); |
303 |
|
} |
304 |
|
#endif |