2 * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
12 #include <openssl/bio.h>
13 #include <openssl/x509_vfy.h>
14 #include <openssl/ssl.h>
16 #include "handshake_helper.h"
19 HANDSHAKE_RESULT *HANDSHAKE_RESULT_new()
21 HANDSHAKE_RESULT *ret = OPENSSL_zalloc(sizeof(*ret));
22 TEST_check(ret != NULL);
26 void HANDSHAKE_RESULT_free(HANDSHAKE_RESULT *result)
30 OPENSSL_free(result->client_npn_negotiated);
31 OPENSSL_free(result->server_npn_negotiated);
32 OPENSSL_free(result->client_alpn_negotiated);
33 OPENSSL_free(result->server_alpn_negotiated);
38 * Since there appears to be no way to extract the sent/received alert
39 * from the SSL object directly, we use the info callback and stash
40 * the result in ex_data.
42 typedef struct handshake_ex_data {
45 int session_ticket_do_not_call;
46 ssl_servername_t servername;
49 typedef struct ctx_data {
50 unsigned char *npn_protocols;
51 size_t npn_protocols_len;
52 unsigned char *alpn_protocols;
53 size_t alpn_protocols_len;
56 /* |ctx_data| itself is stack-allocated. */
57 static void ctx_data_free_data(CTX_DATA *ctx_data)
59 OPENSSL_free(ctx_data->npn_protocols);
60 ctx_data->npn_protocols = NULL;
61 OPENSSL_free(ctx_data->alpn_protocols);
62 ctx_data->alpn_protocols = NULL;
65 static int ex_data_idx;
67 static void info_cb(const SSL *s, int where, int ret)
69 if (where & SSL_CB_ALERT) {
70 HANDSHAKE_EX_DATA *ex_data =
71 (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));
72 if (where & SSL_CB_WRITE) {
73 ex_data->alert_sent = ret;
75 ex_data->alert_received = ret;
80 /* Select the appropriate server CTX.
81 * Returns SSL_TLSEXT_ERR_OK if a match was found.
82 * If |ignore| is 1, returns SSL_TLSEXT_ERR_NOACK on mismatch.
83 * Otherwise, returns SSL_TLSEXT_ERR_ALERT_FATAL on mismatch.
84 * An empty SNI extension also returns SSL_TSLEXT_ERR_NOACK.
86 static int select_server_ctx(SSL *s, void *arg, int ignore)
88 const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
89 HANDSHAKE_EX_DATA *ex_data =
90 (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));
92 if (servername == NULL) {
93 ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
94 return SSL_TLSEXT_ERR_NOACK;
97 if (strcmp(servername, "server2") == 0) {
98 SSL_CTX *new_ctx = (SSL_CTX*)arg;
99 SSL_set_SSL_CTX(s, new_ctx);
101 * Copy over all the SSL_CTX options - reasonable behavior
102 * allows testing of cases where the options between two
103 * contexts differ/conflict
105 SSL_clear_options(s, 0xFFFFFFFFL);
106 SSL_set_options(s, SSL_CTX_get_options(new_ctx));
108 ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;
109 return SSL_TLSEXT_ERR_OK;
110 } else if (strcmp(servername, "server1") == 0) {
111 ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
112 return SSL_TLSEXT_ERR_OK;
114 ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
115 return SSL_TLSEXT_ERR_NOACK;
117 /* Don't set an explicit alert, to test library defaults. */
118 return SSL_TLSEXT_ERR_ALERT_FATAL;
124 * If the server understood the ClientHello extension but
125 * does not recognize the server name, the server SHOULD take one of two
126 * actions: either abort the handshake by sending a fatal-level
127 * unrecognized_name(112) alert or continue the handshake.
129 * This behaviour is up to the application to configure; we test both
130 * configurations to ensure the state machine propagates the result
133 static int servername_ignore_cb(SSL *s, int *ad, void *arg)
135 return select_server_ctx(s, arg, 1);
138 static int servername_reject_cb(SSL *s, int *ad, void *arg)
140 return select_server_ctx(s, arg, 0);
143 static int verify_reject_cb(X509_STORE_CTX *ctx, void *arg) {
144 X509_STORE_CTX_set_error(ctx, X509_V_ERR_APPLICATION_VERIFICATION);
148 static int verify_accept_cb(X509_STORE_CTX *ctx, void *arg) {
152 static int broken_session_ticket_cb(SSL *s, unsigned char *key_name, unsigned char *iv,
153 EVP_CIPHER_CTX *ctx, HMAC_CTX *hctx, int enc)
158 static int do_not_call_session_ticket_cb(SSL *s, unsigned char *key_name,
161 HMAC_CTX *hctx, int enc)
163 HANDSHAKE_EX_DATA *ex_data =
164 (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));
165 ex_data->session_ticket_do_not_call = 1;
169 /* Parse the comma-separated list into TLS format. */
170 static void parse_protos(const char *protos, unsigned char **out, size_t *outlen)
172 size_t len, i, prefix;
174 len = strlen(protos);
176 /* Should never have reuse. */
177 TEST_check(*out == NULL);
179 /* Test values are small, so we omit length limit checks. */
180 *out = OPENSSL_malloc(len + 1);
181 TEST_check(*out != NULL);
185 * foo => '3', 'f', 'o', 'o'
186 * foo,bar => '3', 'f', 'o', 'o', '3', 'b', 'a', 'r'
188 memcpy(*out + 1, protos, len);
193 if ((*out)[i] == ',') {
194 TEST_check(i - 1 - prefix > 0);
195 (*out)[prefix] = i - 1 - prefix;
200 TEST_check(len - prefix > 0);
201 (*out)[prefix] = len - prefix;
204 #ifndef OPENSSL_NO_NEXTPROTONEG
206 * The client SHOULD select the first protocol advertised by the server that it
207 * also supports. In the event that the client doesn't support any of server's
208 * protocols, or the server doesn't advertise any, it SHOULD select the first
209 * protocol that it supports.
211 static int client_npn_cb(SSL *s, unsigned char **out, unsigned char *outlen,
212 const unsigned char *in, unsigned int inlen,
215 CTX_DATA *ctx_data = (CTX_DATA*)(arg);
218 ret = SSL_select_next_proto(out, outlen, in, inlen,
219 ctx_data->npn_protocols,
220 ctx_data->npn_protocols_len);
221 /* Accept both OPENSSL_NPN_NEGOTIATED and OPENSSL_NPN_NO_OVERLAP. */
222 TEST_check(ret == OPENSSL_NPN_NEGOTIATED || ret == OPENSSL_NPN_NO_OVERLAP);
223 return SSL_TLSEXT_ERR_OK;
226 static int server_npn_cb(SSL *s, const unsigned char **data,
227 unsigned int *len, void *arg)
229 CTX_DATA *ctx_data = (CTX_DATA*)(arg);
230 *data = ctx_data->npn_protocols;
231 *len = ctx_data->npn_protocols_len;
232 return SSL_TLSEXT_ERR_OK;
237 * The server SHOULD select the most highly preferred protocol that it supports
238 * and that is also advertised by the client. In the event that the server
239 * supports no protocols that the client advertises, then the server SHALL
240 * respond with a fatal "no_application_protocol" alert.
242 static int server_alpn_cb(SSL *s, const unsigned char **out,
243 unsigned char *outlen, const unsigned char *in,
244 unsigned int inlen, void *arg)
246 CTX_DATA *ctx_data = (CTX_DATA*)(arg);
249 /* SSL_select_next_proto isn't const-correct... */
250 unsigned char *tmp_out;
253 * The result points either to |in| or to |ctx_data->alpn_protocols|.
254 * The callback is allowed to point to |in| or to a long-lived buffer,
255 * so we can return directly without storing a copy.
257 ret = SSL_select_next_proto(&tmp_out, outlen,
258 ctx_data->alpn_protocols,
259 ctx_data->alpn_protocols_len, in, inlen);
262 /* Unlike NPN, we don't tolerate a mismatch. */
263 return ret == OPENSSL_NPN_NEGOTIATED ? SSL_TLSEXT_ERR_OK
264 : SSL_TLSEXT_ERR_NOACK;
268 * Configure callbacks and other properties that can't be set directly
269 * in the server/client CONF.
271 static void configure_handshake_ctx(SSL_CTX *server_ctx, SSL_CTX *server2_ctx,
273 const SSL_TEST_EXTRA_CONF *extra,
274 CTX_DATA *server_ctx_data,
275 CTX_DATA *server2_ctx_data,
276 CTX_DATA *client_ctx_data)
278 unsigned char *ticket_keys;
279 size_t ticket_key_len;
281 switch (extra->client.verify_callback) {
282 case SSL_TEST_VERIFY_ACCEPT_ALL:
283 SSL_CTX_set_cert_verify_callback(client_ctx, &verify_accept_cb,
286 case SSL_TEST_VERIFY_REJECT_ALL:
287 SSL_CTX_set_cert_verify_callback(client_ctx, &verify_reject_cb,
294 /* link the two contexts for SNI purposes */
295 switch (extra->server.servername_callback) {
296 case SSL_TEST_SERVERNAME_IGNORE_MISMATCH:
297 SSL_CTX_set_tlsext_servername_callback(server_ctx, servername_ignore_cb);
298 SSL_CTX_set_tlsext_servername_arg(server_ctx, server2_ctx);
300 case SSL_TEST_SERVERNAME_REJECT_MISMATCH:
301 SSL_CTX_set_tlsext_servername_callback(server_ctx, servername_reject_cb);
302 SSL_CTX_set_tlsext_servername_arg(server_ctx, server2_ctx);
309 * The initial_ctx/session_ctx always handles the encrypt/decrypt of the
310 * session ticket. This ticket_key callback is assigned to the second
311 * session (assigned via SNI), and should never be invoked
313 if (server2_ctx != NULL)
314 SSL_CTX_set_tlsext_ticket_key_cb(server2_ctx,
315 do_not_call_session_ticket_cb);
317 if (extra->server.broken_session_ticket) {
318 SSL_CTX_set_tlsext_ticket_key_cb(server_ctx, broken_session_ticket_cb);
320 #ifndef OPENSSL_NO_NEXTPROTONEG
321 if (extra->server.npn_protocols != NULL) {
322 parse_protos(extra->server.npn_protocols,
323 &server_ctx_data->npn_protocols,
324 &server_ctx_data->npn_protocols_len);
325 SSL_CTX_set_next_protos_advertised_cb(server_ctx, server_npn_cb,
328 if (extra->server2.npn_protocols != NULL) {
329 parse_protos(extra->server2.npn_protocols,
330 &server2_ctx_data->npn_protocols,
331 &server2_ctx_data->npn_protocols_len);
332 TEST_check(server2_ctx != NULL);
333 SSL_CTX_set_next_protos_advertised_cb(server2_ctx, server_npn_cb,
336 if (extra->client.npn_protocols != NULL) {
337 parse_protos(extra->client.npn_protocols,
338 &client_ctx_data->npn_protocols,
339 &client_ctx_data->npn_protocols_len);
340 SSL_CTX_set_next_proto_select_cb(client_ctx, client_npn_cb,
344 if (extra->server.alpn_protocols != NULL) {
345 parse_protos(extra->server.alpn_protocols,
346 &server_ctx_data->alpn_protocols,
347 &server_ctx_data->alpn_protocols_len);
348 SSL_CTX_set_alpn_select_cb(server_ctx, server_alpn_cb, server_ctx_data);
350 if (extra->server2.alpn_protocols != NULL) {
351 TEST_check(server2_ctx != NULL);
352 parse_protos(extra->server2.alpn_protocols,
353 &server2_ctx_data->alpn_protocols,
354 &server2_ctx_data->alpn_protocols_len);
355 SSL_CTX_set_alpn_select_cb(server2_ctx, server_alpn_cb, server2_ctx_data);
357 if (extra->client.alpn_protocols != NULL) {
358 unsigned char *alpn_protos = NULL;
359 size_t alpn_protos_len;
360 parse_protos(extra->client.alpn_protocols,
361 &alpn_protos, &alpn_protos_len);
362 /* Reversed return value convention... */
363 TEST_check(SSL_CTX_set_alpn_protos(client_ctx, alpn_protos,
364 alpn_protos_len) == 0);
365 OPENSSL_free(alpn_protos);
369 * Use fixed session ticket keys so that we can decrypt a ticket created with
370 * one CTX in another CTX. Don't address server2 for the moment.
372 ticket_key_len = SSL_CTX_set_tlsext_ticket_keys(server_ctx, NULL, 0);
373 ticket_keys = OPENSSL_zalloc(ticket_key_len);
374 TEST_check(ticket_keys != NULL);
375 TEST_check(SSL_CTX_set_tlsext_ticket_keys(server_ctx, ticket_keys,
376 ticket_key_len) == 1);
377 OPENSSL_free(ticket_keys);
379 #ifndef OPENSSL_NO_CT
380 TEST_check(SSL_CTX_set_default_ctlog_list_file(client_ctx));
381 switch (extra->client.ct_validation) {
382 case SSL_TEST_CT_VALIDATION_PERMISSIVE:
383 TEST_check(SSL_CTX_enable_ct(client_ctx, SSL_CT_VALIDATION_PERMISSIVE));
385 case SSL_TEST_CT_VALIDATION_STRICT:
386 TEST_check(SSL_CTX_enable_ct(client_ctx, SSL_CT_VALIDATION_STRICT));
388 case SSL_TEST_CT_VALIDATION_NONE:
394 /* Configure per-SSL callbacks and other properties. */
395 static void configure_handshake_ssl(SSL *server, SSL *client,
396 const SSL_TEST_EXTRA_CONF *extra)
398 if (extra->client.servername != SSL_TEST_SERVERNAME_NONE)
399 SSL_set_tlsext_host_name(client,
400 ssl_servername_name(extra->client.servername));
413 * Note that as of TLS 1.1,
414 * failure to properly close a connection no longer requires that a
415 * session not be resumed. This is a change from TLS 1.0 to conform
416 * with widespread implementation practice.
419 * (a) OpenSSL requires that a connection be shutdown for all protocol versions.
420 * (b) We test lower versions, too.
421 * So we just implement shutdown. We do a full bidirectional shutdown so that we
422 * can compare sent and received close_notify alerts and get some test coverage
423 * for SSL_shutdown as a bonus.
425 static peer_status_t do_handshake_step(SSL *ssl, int shutdown)
429 ret = shutdown ? SSL_shutdown(ssl) : SSL_do_handshake(ssl);
433 } else if (ret == 0) {
434 return shutdown ? PEER_RETRY : PEER_ERROR;
436 int error = SSL_get_error(ssl, ret);
437 /* Memory bios should never block with SSL_ERROR_WANT_WRITE. */
438 if (error == SSL_ERROR_WANT_READ)
446 /* Both parties succeeded. */
448 /* Client errored. */
450 /* Server errored. */
452 /* Peers are in inconsistent state. */
454 /* One or both peers not done. */
456 } handshake_status_t;
459 * Determine the handshake outcome.
460 * last_status: the status of the peer to have acted last.
461 * previous_status: the status of the peer that didn't act last.
462 * client_spoke_last: 1 if the client went last.
464 static handshake_status_t handshake_status(peer_status_t last_status,
465 peer_status_t previous_status,
466 int client_spoke_last)
468 switch (last_status) {
470 switch (previous_status) {
472 /* Both succeeded. */
473 return HANDSHAKE_SUCCESS;
475 /* Let the first peer finish. */
476 return HANDSHAKE_RETRY;
479 * Second peer succeeded despite the fact that the first peer
480 * already errored. This shouldn't happen.
482 return INTERNAL_ERROR;
486 if (previous_status == PEER_RETRY) {
487 /* Neither peer is done. */
488 return HANDSHAKE_RETRY;
491 * Deadlock: second peer is waiting for more input while first
492 * peer thinks they're done (no more input is coming).
494 return INTERNAL_ERROR;
497 switch (previous_status) {
500 * First peer succeeded but second peer errored.
501 * TODO(emilia): we should be able to continue here (with some
502 * application data?) to ensure the first peer receives the
503 * alert / close_notify.
505 return client_spoke_last ? CLIENT_ERROR : SERVER_ERROR;
507 /* We errored; let the peer finish. */
508 return HANDSHAKE_RETRY;
510 /* Both peers errored. Return the one that errored first. */
511 return client_spoke_last ? SERVER_ERROR : CLIENT_ERROR;
514 /* Control should never reach here. */
515 return INTERNAL_ERROR;
518 /* Convert unsigned char buf's that shouldn't contain any NUL-bytes to char. */
519 static char *dup_str(const unsigned char *in, size_t len)
526 /* Assert that the string does not contain NUL-bytes. */
527 TEST_check(OPENSSL_strnlen((const char*)(in), len) == len);
528 ret = OPENSSL_strndup((const char*)(in), len);
529 TEST_check(ret != NULL);
533 static HANDSHAKE_RESULT *do_handshake_internal(
534 SSL_CTX *server_ctx, SSL_CTX *server2_ctx, SSL_CTX *client_ctx,
535 const SSL_TEST_EXTRA_CONF *extra, SSL_SESSION *session_in,
536 SSL_SESSION **session_out)
538 SSL *server, *client;
539 BIO *client_to_server, *server_to_client;
540 HANDSHAKE_EX_DATA server_ex_data, client_ex_data;
541 CTX_DATA client_ctx_data, server_ctx_data, server2_ctx_data;
542 HANDSHAKE_RESULT *ret = HANDSHAKE_RESULT_new();
543 int client_turn = 1, shutdown = 0;
544 peer_status_t client_status = PEER_RETRY, server_status = PEER_RETRY;
545 handshake_status_t status = HANDSHAKE_RETRY;
546 unsigned char* tick = NULL;
548 SSL_SESSION* sess = NULL;
549 const unsigned char *proto = NULL;
550 /* API dictates unsigned int rather than size_t. */
551 unsigned int proto_len = 0;
553 memset(&server_ctx_data, 0, sizeof(server_ctx_data));
554 memset(&server2_ctx_data, 0, sizeof(server2_ctx_data));
555 memset(&client_ctx_data, 0, sizeof(client_ctx_data));
557 configure_handshake_ctx(server_ctx, server2_ctx, client_ctx, extra,
558 &server_ctx_data, &server2_ctx_data, &client_ctx_data);
560 server = SSL_new(server_ctx);
561 client = SSL_new(client_ctx);
562 TEST_check(server != NULL);
563 TEST_check(client != NULL);
565 configure_handshake_ssl(server, client, extra);
566 if (session_in != NULL) {
567 /* In case we're testing resumption without tickets. */
568 TEST_check(SSL_CTX_add_session(server_ctx, session_in));
569 TEST_check(SSL_set_session(client, session_in));
572 memset(&server_ex_data, 0, sizeof(server_ex_data));
573 memset(&client_ex_data, 0, sizeof(client_ex_data));
575 ret->result = SSL_TEST_INTERNAL_ERROR;
577 client_to_server = BIO_new(BIO_s_mem());
578 server_to_client = BIO_new(BIO_s_mem());
580 TEST_check(client_to_server != NULL && server_to_client != NULL);
582 /* Non-blocking bio. */
583 BIO_set_nbio(client_to_server, 1);
584 BIO_set_nbio(server_to_client, 1);
586 SSL_set_connect_state(client);
587 SSL_set_accept_state(server);
589 /* The bios are now owned by the SSL object. */
590 SSL_set_bio(client, server_to_client, client_to_server);
591 TEST_check(BIO_up_ref(server_to_client) > 0);
592 TEST_check(BIO_up_ref(client_to_server) > 0);
593 SSL_set_bio(server, client_to_server, server_to_client);
595 ex_data_idx = SSL_get_ex_new_index(0, "ex data", NULL, NULL, NULL);
596 TEST_check(ex_data_idx >= 0);
598 TEST_check(SSL_set_ex_data(server, ex_data_idx,
599 &server_ex_data) == 1);
600 TEST_check(SSL_set_ex_data(client, ex_data_idx,
601 &client_ex_data) == 1);
603 SSL_set_info_callback(server, &info_cb);
604 SSL_set_info_callback(client, &info_cb);
607 * Half-duplex handshake loop.
608 * Client and server speak to each other synchronously in the same process.
609 * We use non-blocking BIOs, so whenever one peer blocks for read, it
610 * returns PEER_RETRY to indicate that it's the other peer's turn to write.
611 * The handshake succeeds once both peers have succeeded. If one peer
612 * errors out, we also let the other peer retry (and presumably fail).
616 client_status = do_handshake_step(client, shutdown);
617 status = handshake_status(client_status, server_status,
618 1 /* client went last */);
620 server_status = do_handshake_step(server, shutdown);
621 status = handshake_status(server_status, client_status,
622 0 /* server went last */);
626 case HANDSHAKE_SUCCESS:
628 ret->result = SSL_TEST_SUCCESS;
631 client_status = server_status = PEER_RETRY;
637 ret->result = SSL_TEST_CLIENT_FAIL;
640 ret->result = SSL_TEST_SERVER_FAIL;
643 ret->result = SSL_TEST_INTERNAL_ERROR;
645 case HANDSHAKE_RETRY:
652 ret->server_alert_sent = server_ex_data.alert_sent;
653 ret->server_alert_received = client_ex_data.alert_received;
654 ret->client_alert_sent = client_ex_data.alert_sent;
655 ret->client_alert_received = server_ex_data.alert_received;
656 ret->server_protocol = SSL_version(server);
657 ret->client_protocol = SSL_version(client);
658 ret->servername = server_ex_data.servername;
659 if ((sess = SSL_get0_session(client)) != NULL)
660 SSL_SESSION_get0_ticket(sess, &tick, &tick_len);
661 if (tick == NULL || tick_len == 0)
662 ret->session_ticket = SSL_TEST_SESSION_TICKET_NO;
664 ret->session_ticket = SSL_TEST_SESSION_TICKET_YES;
665 ret->session_ticket_do_not_call = server_ex_data.session_ticket_do_not_call;
667 #ifndef OPENSSL_NO_NEXTPROTONEG
668 SSL_get0_next_proto_negotiated(client, &proto, &proto_len);
669 ret->client_npn_negotiated = dup_str(proto, proto_len);
671 SSL_get0_next_proto_negotiated(server, &proto, &proto_len);
672 ret->server_npn_negotiated = dup_str(proto, proto_len);
675 SSL_get0_alpn_selected(client, &proto, &proto_len);
676 ret->client_alpn_negotiated = dup_str(proto, proto_len);
678 SSL_get0_alpn_selected(server, &proto, &proto_len);
679 ret->server_alpn_negotiated = dup_str(proto, proto_len);
681 ret->client_resumed = SSL_session_reused(client);
682 ret->server_resumed = SSL_session_reused(server);
684 if (session_out != NULL)
685 *session_out = SSL_get1_session(client);
687 ctx_data_free_data(&server_ctx_data);
688 ctx_data_free_data(&server2_ctx_data);
689 ctx_data_free_data(&client_ctx_data);
696 HANDSHAKE_RESULT *do_handshake(SSL_CTX *server_ctx, SSL_CTX *server2_ctx,
697 SSL_CTX *client_ctx, SSL_CTX *resume_server_ctx,
698 SSL_CTX *resume_client_ctx,
699 const SSL_TEST_CTX *test_ctx)
701 HANDSHAKE_RESULT *result;
702 SSL_SESSION *session = NULL;
704 result = do_handshake_internal(server_ctx, server2_ctx, client_ctx,
705 &test_ctx->extra, NULL, &session);
706 if (test_ctx->handshake_mode == SSL_TEST_HANDSHAKE_SIMPLE)
709 TEST_check(test_ctx->handshake_mode == SSL_TEST_HANDSHAKE_RESUME);
711 if (result->result != SSL_TEST_SUCCESS) {
712 result->result = SSL_TEST_FIRST_HANDSHAKE_FAILED;
716 HANDSHAKE_RESULT_free(result);
717 /* We don't support SNI on second handshake yet, so server2_ctx is NULL. */
718 result = do_handshake_internal(resume_server_ctx, NULL, resume_client_ctx,
719 &test_ctx->resume_extra, session, NULL);
721 SSL_SESSION_free(session);