Navigation


Changeset 807:09f8f0c4f4a4 in freeDiameter for tests/testcnx.c


Ignore:
Timestamp:
Aug 24, 2012, 7:15:48 AM (12 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Several changes to support GnuTLS 3.x in a more efficient way

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/testcnx.c

    r795 r807  
    614614        CHECK( 1, ret );
    615615       
     616        #ifdef GNUTLS_VERSION_300
     617        {
     618                /* We import these CA in the trust list */
     619                gnutls_x509_crt_t * calist;
     620                unsigned int cacount = 0;
     621               
     622                CHECK_GNUTLS_DO( ret = gnutls_x509_crt_list_import2(&calist, &cacount, &ca, GNUTLS_X509_FMT_PEM,
     623                                                        GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED), );
     624                CHECK( 1, cacount );
     625
     626                CHECK_GNUTLS_DO( ret = gnutls_x509_trust_list_add_cas (fd_g_config->cnf_sec_data.trustlist, calist, cacount, 0), );
     627                CHECK( 1, ret );
     628        }
     629               
     630        /* Use certificate verification during the handshake */
     631        gnutls_certificate_set_verify_function (fd_g_config->cnf_sec_data.credentials, fd_tls_verify_credentials_2);
     632       
     633        #endif /* GNUTLS_VERSION_300 */
     634                                                       
     635       
    616636        /* Set the server credentials (in config) */
    617637        CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( fd_g_config->cnf_sec_data.credentials,
     
    12011221       
    12021222        /* Basic operation tested successfully, now test we detect error conditions */
    1203        
     1223
    12041224        /* Untrusted certificate, TCP */
    12051225        {
     
    12381258                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
    12391259                CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
     1260                fd_cnx_destroy(server_side);
     1261               
    12401262                CHECK( 0, pthread_join(thr, NULL) );
    12411263               
    12421264                /* Now close the connection */
    12431265                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
    1244                 fd_cnx_destroy(server_side);
    12451266                CHECK( 0, pthread_join(thr, NULL) );
    12461267               
     
    12671288                /* Set the CA */
    12681289                CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &notrust_ca, GNUTLS_X509_FMT_PEM), );
    1269                 /* TODO: fix me.
    1270                  We should not get stuck when the server fails the handshake but the client succeeds.
    1271                  However, at the moment we do get stuck.
    1272                  FFS, is this a test problem or a problem in the code?
    1273                  
    1274                  CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
    1275                  */
     1290                CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
    12761291                CHECK( 1, ret );
    12771292                /* Set the key */
     
    12941309                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
    12951310                CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
     1311                fd_cnx_destroy(server_side);
    12961312                CHECK( 0, pthread_join(thr, NULL) );
    12971313               
    12981314                /* Now close the connection */
    12991315                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
    1300                 fd_cnx_destroy(server_side);
    13011316                CHECK( 0, pthread_join(thr, NULL) );
    13021317               
     
    13431358                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
    13441359                CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
     1360                fd_cnx_destroy(server_side);
    13451361                CHECK( 0, pthread_join(thr, NULL) );
    13461362               
    13471363                /* Now close the connection */
    13481364                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
    1349                 fd_cnx_destroy(server_side);
    13501365                CHECK( 0, pthread_join(thr, NULL) );
    13511366               
     
    14211436                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
    14221437                CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
     1438                fd_cnx_destroy(server_side);
    14231439                CHECK( 0, pthread_join(thr, NULL) );
    14241440               
    14251441                /* Now close the connection */
    14261442                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
    1427                 fd_cnx_destroy(server_side);
    14281443                CHECK( 0, pthread_join(thr, NULL) );
    14291444               
Note: See TracChangeset for help on using the changeset viewer.