Changeset 6054


Ignore:
Timestamp:
Aug 28, 2019 12:02:50 PM (3 years ago)
Author:
riza
Message:

Fixed #2221: When using Openssl as TLS backend, close notify alert is not sent before closing the connection.

Location:
pjproject/trunk/pjlib/src/pj
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/ssl_sock_imp_common.c

    r6004 r6054  
    12821282    pj_ioqueue_op_key_init(&ssock->handshake_op_key, 
    12831283                           sizeof(pj_ioqueue_op_key_t)); 
     1284    pj_ioqueue_op_key_init(&ssock->shutdown_op_key, 
     1285                           sizeof(pj_ioqueue_op_key_t)); 
    12841286 
    12851287    /* Create secure socket mutex */ 
  • pjproject/trunk/pjlib/src/pj/ssl_sock_imp_common.h

    r6022 r6054  
    108108    enum ssl_state        ssl_state; 
    109109    pj_ioqueue_op_key_t   handshake_op_key; 
     110    pj_ioqueue_op_key_t   shutdown_op_key; 
    110111    pj_timer_entry        timer; 
    111112    pj_status_t           verify_status; 
  • pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c

    r6053 r6054  
    11691169    /* Destroy SSL instance */ 
    11701170    if (ossock->ossl_ssl) { 
    1171         /** 
    1172          * Avoid calling SSL_shutdown() if handshake wasn't completed. 
    1173          * OpenSSL 1.0.2f complains if SSL_shutdown() is called during an 
    1174          * SSL handshake, while previous versions always return 0.        
    1175          */ 
    1176         if (SSL_in_init(ossock->ossl_ssl) == 0) { 
    1177             SSL_shutdown(ossock->ossl_ssl); 
    1178         }        
    11791171        SSL_free(ossock->ossl_ssl); /* this will also close BIOs */ 
    11801172        ossock->ossl_ssl = NULL; 
     
    11971189static void ssl_reset_sock_state(pj_ssl_sock_t *ssock) 
    11981190{ 
     1191    ossl_sock_t *ossock = (ossl_sock_t *)ssock; 
     1192    /** 
     1193     * Avoid calling SSL_shutdown() if handshake wasn't completed. 
     1194     * OpenSSL 1.0.2f complains if SSL_shutdown() is called during an 
     1195     * SSL handshake, while previous versions always return 0. 
     1196     */ 
     1197    if (ossock->ossl_ssl && SSL_in_init(ossock->ossl_ssl) == 0) { 
     1198        int ret = SSL_shutdown(ossock->ossl_ssl); 
     1199        if (ret == 0) { 
     1200            /* Flush data to send close notify. */ 
     1201            flush_circ_buf_output(ssock, &ssock->shutdown_op_key, 0, 0); 
     1202        } 
     1203    } 
     1204 
    11991205    pj_lock_acquire(ssock->write_mutex); 
    12001206    ssock->ssl_state = SSL_STATE_NULL; 
Note: See TracChangeset for help on using the changeset viewer.