Navigation


Changeset 543:40141acabee7 in freeDiameter


Ignore:
Timestamp:
Sep 14, 2010, 1:31:27 PM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Fix behavior of TLS/SCTP when only one peer does not accept the remote certificate

Location:
freeDiameter
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • freeDiameter/cnxctx.c

    r542 r543  
    995995int fd_tls_verify_credentials(gnutls_session_t session, struct cnxctx * conn, int verbose)
    996996{
    997         int i;
     997        int i, ret = 0;
    998998        unsigned int gtret;
    999999        const gnutls_datum_t *cert_list;
     
    11761176                CHECK_GNUTLS_DO( gnutls_x509_crt_import (cert, &cert_list[i], GNUTLS_X509_FMT_DER), return EINVAL);
    11771177               
    1178                 /* When gnutls 2.10.1 is around, we should use gnutls_certificate_set_verify_function */
    1179                
    11801178                GNUTLS_TRACE( deadline = gnutls_x509_crt_get_expiration_time(cert) );
    11811179                if ((deadline != (time_t)-1) && (deadline < now)) {
     
    11841182                                fd_log_debug(" - The certificate %d in the chain is expired\n", i);
    11851183                        }
    1186                         return EINVAL;
     1184                        ret = EINVAL;
    11871185                }
    11881186               
     
    11931191                                fd_log_debug(" - The certificate %d in the chain is not yet activated\n", i);
    11941192                        }
    1195                         return EINVAL;
     1193                        ret = EINVAL;
    11961194                }
    11971195               
     
    12021200                                        fd_log_debug(" - The certificate hostname does not match '%s'\n", conn->cc_tls_para.cn);
    12031201                                }
    1204                                 return EINVAL;
     1202                                ret = EINVAL;
    12051203                        }
    12061204                }
     
    12091207        }
    12101208
    1211         return 0;
     1209        return ret;
    12121210}
    12131211
     
    12561254                int ret;
    12571255               
    1258                 /* When gnutls 2.10.1 is around, we should use gnutls_certificate_set_verify_function */
     1256                /* When gnutls 2.10.1 is around, we should use gnutls_certificate_set_verify_function and fd_tls_verify_credentials, so that handshake fails directly. */
    12591257               
    12601258                CHECK_GNUTLS_DO( ret = gnutls_handshake(conn->cc_tls_para.session),
     
    12791277        if (conn->cc_sctp_para.pairs > 1) {
    12801278#ifndef DISABLE_SCTP
     1279                /* Start reading the messages from the master session. That way, if the remote peer closed, we are not stuck inside handshake */
     1280                CHECK_FCT(fd_sctps_startthreads(conn, 0));
     1281               
    12811282                /* Resume all additional sessions from the master one. */
    12821283                CHECK_FCT(fd_sctps_handshake_others(conn, priority, alt_creds));
    12831284
    12841285                /* Start decrypting the messages from all threads and queuing them in target queue */
    1285                 CHECK_FCT(fd_sctps_startthreads(conn));
     1286                CHECK_FCT(fd_sctps_startthreads(conn, 1));
    12861287#endif /* DISABLE_SCTP */
    12871288        } else {
  • freeDiameter/cnxctx.h

    r403 r543  
    128128int fd_sctps_init(struct cnxctx * conn);
    129129int fd_sctps_handshake_others(struct cnxctx * conn, char * priority, void * alt_creds);
    130 int fd_sctps_startthreads(struct cnxctx * conn);
     130int fd_sctps_startthreads(struct cnxctx * conn, int others);
    131131void fd_sctps_bye(struct cnxctx * conn);
    132132void fd_sctps_waitthreadsterm(struct cnxctx * conn);
  • freeDiameter/sctps.c

    r455 r543  
    598598}
    599599
    600 /* Receive messages from all stream pairs */
    601 int fd_sctps_startthreads(struct cnxctx * conn)
     600/* Receive messages from others ? all other stream pairs : the master pair */
     601int fd_sctps_startthreads(struct cnxctx * conn, int others)
    602602{
    603603        uint16_t i;
     
    606606        CHECK_PARAMS( conn && conn->cc_sctps_data.array );
    607607       
    608         for (i = 0; i < conn->cc_sctp_para.pairs; i++) {
    609                
    610                 /* Start the decipher thread */
    611                 CHECK_POSIX( pthread_create( &conn->cc_sctps_data.array[i].thr, NULL, decipher, &conn->cc_sctps_data.array[i] ) );
     608        if (others) {
     609                for (i = 1; i < conn->cc_sctp_para.pairs; i++) {
     610
     611                        /* Start the decipher thread */
     612                        CHECK_POSIX( pthread_create( &conn->cc_sctps_data.array[i].thr, NULL, decipher, &conn->cc_sctps_data.array[i] ) );
     613                }
     614        } else {
     615                CHECK_POSIX( pthread_create( &conn->cc_sctps_data.array[0].thr, NULL, decipher, &conn->cc_sctps_data.array[0] ) );
    612616        }
    613617        return 0;
Note: See TracChangeset for help on using the changeset viewer.