summaryrefslogtreecommitdiffstats
path: root/test/ssl_test.c
diff options
context:
space:
mode:
authorEmilia Kasper <emilia@openssl.org>2016-06-20 17:20:25 +0200
committerEmilia Kasper <emilia@openssl.org>2016-06-28 17:26:24 +0200
commitd2b23cd2b077de8507c49f632e20dfcdb653a35b (patch)
tree3a8a980e199c680d7e296468439c6f53d05fa1a0 /test/ssl_test.c
parent2cdce3e32f0f70470d676352410557b626bc9d01 (diff)
SSL test framework: port SNI tests
Observe that the old tests were partly ill-defined: setting sn_server1 but not sn_server2 in ssltest_old.c does not enable the SNI callback. Fix this, and also explicitly test both flavours of SNI mismatch (ignore / fatal alert). Tests still pass. Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'test/ssl_test.c')
-rw-r--r--test/ssl_test.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/test/ssl_test.c b/test/ssl_test.c
index 537d4b0e5a..060f73eeba 100644
--- a/test/ssl_test.c
+++ b/test/ssl_test.c
@@ -125,14 +125,13 @@ static int check_protocol(HANDSHAKE_RESULT result, SSL_TEST_CTX *test_ctx)
static int check_servername(HANDSHAKE_RESULT result, SSL_TEST_CTX *test_ctx)
{
- if (test_ctx->servername != SSL_TEST_SERVERNAME_NONE
- && result.servername != test_ctx->servername) {
- fprintf(stderr, "Client ServerName mismatch, expected %s, got %s\n.",
- ssl_servername_name(test_ctx->servername),
- ssl_servername_name(result.servername));
- return 0;
+ if (result.servername != test_ctx->expected_servername) {
+ fprintf(stderr, "Client ServerName mismatch, expected %s, got %s\n.",
+ ssl_servername_name(test_ctx->expected_servername),
+ ssl_servername_name(result.servername));
+ return 0;
}
- return 1;
+ return 1;
}
static int check_session_ticket(HANDSHAKE_RESULT result, SSL_TEST_CTX *test_ctx)
@@ -176,40 +175,42 @@ static int execute_test(SSL_TEST_FIXTURE fixture)
SSL_CTX *server_ctx = NULL, *server2_ctx = NULL, *client_ctx = NULL;
SSL_TEST_CTX *test_ctx = NULL;
HANDSHAKE_RESULT result;
- const char *server2;
test_ctx = SSL_TEST_CTX_create(conf, fixture.test_app);
if (test_ctx == NULL)
goto err;
- /* Use ServerName to detect if we're testing SNI. */
- server2 = (test_ctx->servername != SSL_TEST_SERVERNAME_NONE) ? "server2"
- : "server";
-
#ifndef OPENSSL_NO_DTLS
if (test_ctx->method == SSL_TEST_METHOD_DTLS) {
server_ctx = SSL_CTX_new(DTLS_server_method());
- server2_ctx = SSL_CTX_new(DTLS_server_method());
+ if (test_ctx->servername_callback != SSL_TEST_SERVERNAME_CB_NONE) {
+ server2_ctx = SSL_CTX_new(DTLS_server_method());
+ OPENSSL_assert(server2_ctx != NULL);
+ }
client_ctx = SSL_CTX_new(DTLS_client_method());
}
#endif
if (test_ctx->method == SSL_TEST_METHOD_TLS) {
server_ctx = SSL_CTX_new(TLS_server_method());
- server2_ctx = SSL_CTX_new(TLS_server_method());
+ if (test_ctx->servername_callback != SSL_TEST_SERVERNAME_CB_NONE) {
+ server2_ctx = SSL_CTX_new(TLS_server_method());
+ OPENSSL_assert(server2_ctx != NULL);
+ }
client_ctx = SSL_CTX_new(TLS_client_method());
}
- OPENSSL_assert(server_ctx != NULL && server2_ctx != NULL &&
- client_ctx != NULL);
+ OPENSSL_assert(server_ctx != NULL && client_ctx != NULL);
OPENSSL_assert(CONF_modules_load(conf, fixture.test_app, 0) > 0);
if (!SSL_CTX_config(server_ctx, "server")
- || !SSL_CTX_config(server2_ctx, server2)
|| !SSL_CTX_config(client_ctx, "client")) {
goto err;
}
+ if (server2_ctx != NULL && !SSL_CTX_config(server2_ctx, "server2"))
+ goto err;
+
result = do_handshake(server_ctx, server2_ctx, client_ctx, test_ctx);
ret = check_test(result, test_ctx);
an>name[80]; /* device name */ int argsize; /* size of the argument */ void *driver_data; /* private data for driver */ int status; /* flag - read only */ void *private_data; /* private data for the caller */ void (*private_free)(struct snd_seq_device *device); struct list_head list; /* link to next device */ }; /* driver operators * init_device: * Initialize the device with given parameters. * Typically, * 1. call snd_hwdep_new * 2. allocate private data and initialize it * 3. call snd_hwdep_register * 4. store the instance to dev->driver_data pointer. * * free_device: * Release the private data. * Typically, call snd_device_free(dev->card, dev->driver_data) */ struct snd_seq_dev_ops { int (*init_device)(struct snd_seq_device *dev); int (*free_device)(struct snd_seq_device *dev); }; /* * prototypes */ void snd_seq_device_load_drivers(void); int snd_seq_device_new(struct snd_card *card, int device, char *id, int argsize, struct snd_seq_device **result); int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry, int argsize); int snd_seq_device_unregister_driver(char *id); #define SNDRV_SEQ_DEVICE_ARGPTR(dev) (void *)((char *)(dev) + sizeof(struct snd_seq_device)) /* * id strings for generic devices */ #define SNDRV_SEQ_DEV_ID_MIDISYNTH "seq-midi" #define SNDRV_SEQ_DEV_ID_OPL3 "opl3-synth" #endif /* __SOUND_SEQ_DEVICE_H */