Classes | Macros | Typedefs | Enumerations | Functions | Variables
ssl_transport_security_test.cc File Reference
#include "src/core/tsi/ssl_transport_security.h"
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/pem.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/iomgr/load_file.h"
#include "src/core/lib/security/security_connector/security_connector.h"
#include "src/core/tsi/transport_security.h"
#include "src/core/tsi/transport_security_interface.h"
#include "test/core/tsi/transport_security_test_lib.h"
#include "test/core/util/test_config.h"
Include dependency graph for ssl_transport_security_test.cc:

Go to the source code of this file.

Classes

struct  ssl_alpn_lib
 
struct  ssl_key_cert_lib
 
struct  ssl_tsi_test_fixture
 

Macros

#define SSL_TSI_TEST_ALPN1   "foo"
 
#define SSL_TSI_TEST_ALPN2   "toto"
 
#define SSL_TSI_TEST_ALPN3   "baz"
 
#define SSL_TSI_TEST_ALPN_NUM   2
 
#define SSL_TSI_TEST_BAD_SERVER_KEY_CERT_PAIRS_NUM   1
 
#define SSL_TSI_TEST_CREDENTIALS_DIR   "src/core/tsi/test_creds/"
 
#define SSL_TSI_TEST_SERVER_KEY_CERT_PAIRS_NUM   2
 
#define SSL_TSI_TEST_WRONG_SNI   "test.google.cn"
 

Typedefs

typedef enum AlpnMode AlpnMode
 
typedef struct ssl_alpn_lib ssl_alpn_lib
 
typedef struct ssl_key_cert_lib ssl_key_cert_lib
 
typedef struct ssl_tsi_test_fixture ssl_tsi_test_fixture
 

Enumerations

enum  AlpnMode {
  NO_ALPN, ALPN_CLIENT_NO_SERVER, ALPN_SERVER_NO_CLIENT, ALPN_CLIENT_SERVER_OK,
  ALPN_CLIENT_SERVER_MISMATCH
}
 

Functions

static void check_alpn (ssl_tsi_test_fixture *ssl_fixture, const tsi_peer *peer)
 
static const tsi_peer_propertycheck_basic_authenticated_peer_and_get_common_name (const tsi_peer *peer)
 
static void check_client_peer (ssl_tsi_test_fixture *ssl_fixture, tsi_peer *peer)
 
static bool check_property (tsi_peer *peer, const char *property_name, const char *property_value)
 
static void check_security_level (const tsi_peer *peer)
 
void check_server0_peer (tsi_peer *peer)
 
void check_server1_peer (tsi_peer *peer)
 
static void check_session_reusage (ssl_tsi_test_fixture *ssl_fixture, tsi_peer *peer)
 
static bool is_slow_build ()
 
static char * load_file (const char *dir_path, const char *file_name)
 
int main (int argc, char **argv)
 
static void ssl_test_check_handshaker_peers (tsi_test_fixture *fixture)
 
static void ssl_test_destruct (tsi_test_fixture *fixture)
 
static void ssl_test_pem_key_cert_pair_destroy (tsi_ssl_pem_key_cert_pair kp)
 
static void ssl_test_setup_handshakers (tsi_test_fixture *fixture)
 
void ssl_tsi_test_do_handshake ()
 
void ssl_tsi_test_do_handshake_alpn_client_no_server ()
 
void ssl_tsi_test_do_handshake_alpn_client_server_mismatch ()
 
void ssl_tsi_test_do_handshake_alpn_client_server_ok ()
 
void ssl_tsi_test_do_handshake_alpn_server_no_client ()
 
void ssl_tsi_test_do_handshake_session_cache ()
 
void ssl_tsi_test_do_handshake_small_handshake_buffer ()
 
void ssl_tsi_test_do_handshake_tiny_handshake_buffer ()
 
void ssl_tsi_test_do_handshake_with_bad_client_cert ()
 
void ssl_tsi_test_do_handshake_with_bad_server_cert ()
 
void ssl_tsi_test_do_handshake_with_client_authentication ()
 
void ssl_tsi_test_do_handshake_with_client_authentication_and_root_store ()
 
void ssl_tsi_test_do_handshake_with_custom_bio_pair ()
 
void ssl_tsi_test_do_handshake_with_root_store ()
 
void ssl_tsi_test_do_handshake_with_server_name_indication_exact_domain ()
 
void ssl_tsi_test_do_handshake_with_server_name_indication_wild_star_domain ()
 
void ssl_tsi_test_do_handshake_with_wrong_server_name_indication ()
 
void ssl_tsi_test_do_round_trip_for_all_configs ()
 
void ssl_tsi_test_do_round_trip_odd_buffer_size ()
 
void ssl_tsi_test_do_round_trip_with_error_on_stack ()
 
void ssl_tsi_test_duplicate_root_certificates ()
 
void ssl_tsi_test_extract_cert_chain ()
 
void ssl_tsi_test_extract_x509_subject_names ()
 
static tsi_test_fixturessl_tsi_test_fixture_create ()
 
static void ssl_tsi_test_handshaker_factory_destructor (tsi_ssl_handshaker_factory *factory)
 
void ssl_tsi_test_handshaker_factory_internals ()
 
void test_tsi_ssl_client_handshaker_factory_bad_params ()
 
void test_tsi_ssl_client_handshaker_factory_refcounting ()
 
void test_tsi_ssl_server_handshaker_factory_refcounting ()
 

Variables

static bool handshaker_factory_destructor_called
 
const size_t kSessionTicketEncryptionKeySize = 48
 
static const tsi_ssl_handshaker_factory_vtableoriginal_vtable
 
static tsi_ssl_handshaker_factory_vtable test_handshaker_factory_vtable
 
static tsi_tls_version test_tls_version = tsi_tls_version::TSI_TLS1_3
 
static const struct tsi_test_fixture_vtable vtable
 

Macro Definition Documentation

◆ SSL_TSI_TEST_ALPN1

#define SSL_TSI_TEST_ALPN1   "foo"

Definition at line 42 of file ssl_transport_security_test.cc.

◆ SSL_TSI_TEST_ALPN2

#define SSL_TSI_TEST_ALPN2   "toto"

Definition at line 43 of file ssl_transport_security_test.cc.

◆ SSL_TSI_TEST_ALPN3

#define SSL_TSI_TEST_ALPN3   "baz"

Definition at line 44 of file ssl_transport_security_test.cc.

◆ SSL_TSI_TEST_ALPN_NUM

#define SSL_TSI_TEST_ALPN_NUM   2

Definition at line 45 of file ssl_transport_security_test.cc.

◆ SSL_TSI_TEST_BAD_SERVER_KEY_CERT_PAIRS_NUM

#define SSL_TSI_TEST_BAD_SERVER_KEY_CERT_PAIRS_NUM   1

Definition at line 47 of file ssl_transport_security_test.cc.

◆ SSL_TSI_TEST_CREDENTIALS_DIR

#define SSL_TSI_TEST_CREDENTIALS_DIR   "src/core/tsi/test_creds/"

Definition at line 48 of file ssl_transport_security_test.cc.

◆ SSL_TSI_TEST_SERVER_KEY_CERT_PAIRS_NUM

#define SSL_TSI_TEST_SERVER_KEY_CERT_PAIRS_NUM   2

Definition at line 46 of file ssl_transport_security_test.cc.

◆ SSL_TSI_TEST_WRONG_SNI

#define SSL_TSI_TEST_WRONG_SNI   "test.google.cn"

Definition at line 49 of file ssl_transport_security_test.cc.

Typedef Documentation

◆ AlpnMode

typedef enum AlpnMode AlpnMode

◆ ssl_alpn_lib

typedef struct ssl_alpn_lib ssl_alpn_lib

◆ ssl_key_cert_lib

◆ ssl_tsi_test_fixture

Enumeration Type Documentation

◆ AlpnMode

enum AlpnMode
Enumerator
NO_ALPN 
ALPN_CLIENT_NO_SERVER 
ALPN_SERVER_NO_CLIENT 
ALPN_CLIENT_SERVER_OK 
ALPN_CLIENT_SERVER_MISMATCH 

Definition at line 62 of file ssl_transport_security_test.cc.

Function Documentation

◆ check_alpn()

static void check_alpn ( ssl_tsi_test_fixture ssl_fixture,
const tsi_peer peer 
)
static

Definition at line 189 of file ssl_transport_security_test.cc.

◆ check_basic_authenticated_peer_and_get_common_name()

static const tsi_peer_property* check_basic_authenticated_peer_and_get_common_name ( const tsi_peer peer)
static

Definition at line 216 of file ssl_transport_security_test.cc.

◆ check_client_peer()

static void check_client_peer ( ssl_tsi_test_fixture ssl_fixture,
tsi_peer peer 
)
static

Definition at line 300 of file ssl_transport_security_test.cc.

◆ check_property()

static bool check_property ( tsi_peer peer,
const char *  property_name,
const char *  property_value 
)
static

Definition at line 263 of file ssl_transport_security_test.cc.

◆ check_security_level()

static void check_security_level ( const tsi_peer peer)
static

Definition at line 206 of file ssl_transport_security_test.cc.

◆ check_server0_peer()

void check_server0_peer ( tsi_peer peer)

Definition at line 242 of file ssl_transport_security_test.cc.

◆ check_server1_peer()

void check_server1_peer ( tsi_peer peer)

Definition at line 277 of file ssl_transport_security_test.cc.

◆ check_session_reusage()

static void check_session_reusage ( ssl_tsi_test_fixture ssl_fixture,
tsi_peer peer 
)
static

Definition at line 228 of file ssl_transport_security_test.cc.

◆ is_slow_build()

static bool is_slow_build ( )
static

Definition at line 709 of file ssl_transport_security_test.cc.

◆ load_file()

static char* load_file ( const char *  dir_path,
const char *  file_name 
)
static

Definition at line 429 of file ssl_transport_security_test.cc.

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 1056 of file ssl_transport_security_test.cc.

◆ ssl_test_check_handshaker_peers()

static void ssl_test_check_handshaker_peers ( tsi_test_fixture fixture)
static

Definition at line 318 of file ssl_transport_security_test.cc.

◆ ssl_test_destruct()

static void ssl_test_destruct ( tsi_test_fixture fixture)
static

Definition at line 379 of file ssl_transport_security_test.cc.

◆ ssl_test_pem_key_cert_pair_destroy()

static void ssl_test_pem_key_cert_pair_destroy ( tsi_ssl_pem_key_cert_pair  kp)
static

Definition at line 374 of file ssl_transport_security_test.cc.

◆ ssl_test_setup_handshakers()

static void ssl_test_setup_handshakers ( tsi_test_fixture fixture)
static

Definition at line 108 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake()

void ssl_tsi_test_do_handshake ( )

Definition at line 533 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake_alpn_client_no_server()

void ssl_tsi_test_do_handshake_alpn_client_no_server ( )

Definition at line 634 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake_alpn_client_server_mismatch()

void ssl_tsi_test_do_handshake_alpn_client_server_mismatch ( )

Definition at line 654 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake_alpn_client_server_ok()

void ssl_tsi_test_do_handshake_alpn_client_server_ok ( )

Definition at line 664 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake_alpn_server_no_client()

void ssl_tsi_test_do_handshake_alpn_server_no_client ( )

Definition at line 644 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake_session_cache()

void ssl_tsi_test_do_handshake_session_cache ( )

Definition at line 749 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake_small_handshake_buffer()

void ssl_tsi_test_do_handshake_small_handshake_buffer ( )

Definition at line 525 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake_tiny_handshake_buffer()

void ssl_tsi_test_do_handshake_tiny_handshake_buffer ( )

Definition at line 514 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake_with_bad_client_cert()

void ssl_tsi_test_do_handshake_with_bad_client_cert ( )

Definition at line 623 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake_with_bad_server_cert()

void ssl_tsi_test_do_handshake_with_bad_server_cert ( )

Definition at line 613 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake_with_client_authentication()

void ssl_tsi_test_do_handshake_with_client_authentication ( )

Definition at line 550 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake_with_client_authentication_and_root_store()

void ssl_tsi_test_do_handshake_with_client_authentication_and_root_store ( )

Definition at line 560 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake_with_custom_bio_pair()

void ssl_tsi_test_do_handshake_with_custom_bio_pair ( )

Definition at line 1042 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake_with_root_store()

void ssl_tsi_test_do_handshake_with_root_store ( )

Definition at line 540 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake_with_server_name_indication_exact_domain()

void ssl_tsi_test_do_handshake_with_server_name_indication_exact_domain ( )

Definition at line 573 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake_with_server_name_indication_wild_star_domain()

void ssl_tsi_test_do_handshake_with_server_name_indication_wild_star_domain ( )

Definition at line 586 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_handshake_with_wrong_server_name_indication()

void ssl_tsi_test_do_handshake_with_wrong_server_name_indication ( )

Definition at line 600 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_round_trip_for_all_configs()

void ssl_tsi_test_do_round_trip_for_all_configs ( )

Definition at line 674 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_round_trip_odd_buffer_size()

void ssl_tsi_test_do_round_trip_odd_buffer_size ( )

Definition at line 717 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_do_round_trip_with_error_on_stack()

void ssl_tsi_test_do_round_trip_with_error_on_stack ( )

Definition at line 698 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_duplicate_root_certificates()

void ssl_tsi_test_duplicate_root_certificates ( )

Definition at line 899 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_extract_cert_chain()

void ssl_tsi_test_extract_cert_chain ( )

Definition at line 1002 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_extract_x509_subject_names()

void ssl_tsi_test_extract_x509_subject_names ( )

Definition at line 915 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_fixture_create()

static tsi_test_fixture* ssl_tsi_test_fixture_create ( )
static

Definition at line 442 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_handshaker_factory_destructor()

static void ssl_tsi_test_handshaker_factory_destructor ( tsi_ssl_handshaker_factory factory)
static

Definition at line 785 of file ssl_transport_security_test.cc.

◆ ssl_tsi_test_handshaker_factory_internals()

void ssl_tsi_test_handshaker_factory_internals ( )

Definition at line 892 of file ssl_transport_security_test.cc.

◆ test_tsi_ssl_client_handshaker_factory_bad_params()

void test_tsi_ssl_client_handshaker_factory_bad_params ( )

Definition at line 881 of file ssl_transport_security_test.cc.

◆ test_tsi_ssl_client_handshaker_factory_refcounting()

void test_tsi_ssl_client_handshaker_factory_refcounting ( )

Definition at line 797 of file ssl_transport_security_test.cc.

◆ test_tsi_ssl_server_handshaker_factory_refcounting()

void test_tsi_ssl_server_handshaker_factory_refcounting ( )

Definition at line 835 of file ssl_transport_security_test.cc.

Variable Documentation

◆ handshaker_factory_destructor_called

bool handshaker_factory_destructor_called
static

Definition at line 783 of file ssl_transport_security_test.cc.

◆ kSessionTicketEncryptionKeySize

const size_t kSessionTicketEncryptionKeySize = 48

Definition at line 56 of file ssl_transport_security_test.cc.

◆ original_vtable

const tsi_ssl_handshaker_factory_vtable* original_vtable
static

Definition at line 782 of file ssl_transport_security_test.cc.

◆ test_handshaker_factory_vtable

tsi_ssl_handshaker_factory_vtable test_handshaker_factory_vtable
static
Initial value:

Definition at line 794 of file ssl_transport_security_test.cc.

◆ test_tls_version

tsi_tls_version test_tls_version = tsi_tls_version::TSI_TLS1_3
static

Definition at line 60 of file ssl_transport_security_test.cc.

◆ vtable

const struct tsi_test_fixture_vtable vtable
static
ssl_tsi_test_handshaker_factory_destructor
static void ssl_tsi_test_handshaker_factory_destructor(tsi_ssl_handshaker_factory *factory)
Definition: ssl_transport_security_test.cc:785
ssl_test_check_handshaker_peers
static void ssl_test_check_handshaker_peers(tsi_test_fixture *fixture)
Definition: ssl_transport_security_test.cc:318
ssl_test_destruct
static void ssl_test_destruct(tsi_test_fixture *fixture)
Definition: ssl_transport_security_test.cc:379
ssl_test_setup_handshakers
static void ssl_test_setup_handshakers(tsi_test_fixture *fixture)
Definition: ssl_transport_security_test.cc:108


grpc
Author(s):
autogenerated on Fri May 16 2025 03:01:32