@@ -423,24 +423,38 @@ int ssl_pm_clear(SSL *ssl)
423
423
424
424
int ssl_pm_read (SSL * ssl , void * buffer , int len )
425
425
{
426
- int ret ;
427
- struct ssl_pm * ssl_pm = (struct ssl_pm * )ssl -> ssl_pm ;
426
+ int ret ;
427
+ struct ssl_pm * ssl_pm = (struct ssl_pm * )ssl -> ssl_pm ;
428
428
429
- ret = mbedtls_ssl_read (& ssl_pm -> ssl , buffer , (size_t )len );
430
- if (ret < 0 ) {
431
- // lwsl_notice("%s: mbedtls_ssl_read says -0x%x\n", __func__, -ret);
432
- SSL_DEBUG (SSL_PLATFORM_ERROR_LEVEL , "mbedtls_ssl_read() return -0x%x" , - ret );
433
- if (ret == MBEDTLS_ERR_NET_CONN_RESET ||
429
+ ret = mbedtls_ssl_read (& ssl_pm -> ssl , buffer , (size_t )len );
430
+ if (ret < 0 ) {
431
+ // lwsl_notice("%s: mbedtls_ssl_read says -0x%x\n", __func__, -ret);
432
+ SSL_DEBUG (SSL_PLATFORM_ERROR_LEVEL , "mbedtls_ssl_read() return -0x%x" , - ret );
433
+ if (ret == MBEDTLS_ERR_NET_CONN_RESET ||
434
434
#if defined(MBEDTLS_VERSION_NUMBER ) & & MBEDTLS_VERSION_NUMBER >= 0x03000000
435
- ret <= MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ) /* fatal errors */
435
+ ret <= MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ) /* fatal errors */
436
436
#else
437
- ret <= MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE ) /* fatal errors */
437
+ ret <= MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE ) /* fatal errors */
438
438
#endif
439
439
ssl -> err = SSL_ERROR_SYSCALL ;
440
- ret = -1 ;
441
- }
442
440
443
- return ret ;
441
+ switch (ret ) {
442
+ case MBEDTLS_ERR_NET_CONN_RESET :
443
+ ssl -> err = SSL_ERROR_SYSCALL ;
444
+ break ;
445
+ case MBEDTLS_ERR_SSL_WANT_WRITE :
446
+ ssl -> err = SSL_ERROR_WANT_WRITE ;
447
+ break ;
448
+ case MBEDTLS_ERR_SSL_WANT_READ :
449
+ ssl -> err = SSL_ERROR_WANT_READ ;
450
+ break ;
451
+ default :
452
+ break ;
453
+ }
454
+ ret = -1 ;
455
+ }
456
+
457
+ return ret ;
444
458
}
445
459
446
460
/*
0 commit comments