/*
- * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
* Copyright 2005 Nokia. All rights reserved.
*
if (servername) {
if (s_ctx2 != NULL && sn_server2 != NULL &&
- !strcasecmp(servername, sn_server2)) {
+ !OPENSSL_strcasecmp(servername, sn_server2)) {
BIO_printf(bio_stdout, "Switching server context.\n");
SSL_set_SSL_CTX(s, s_ctx2);
}
* verify_alpn.
*/
alpn_selected = OPENSSL_malloc(*outlen);
+ if (alpn_selected == NULL) {
+ fprintf(stderr, "failed to allocate memory\n");
+ OPENSSL_free(protos);
+ abort();
+ }
memcpy(alpn_selected, *out, *outlen);
*out = alpn_selected;
OPENSSL_free(alpn_selected);
alpn_selected = NULL;
+ if (client_proto == NULL && client_proto_len != 0) {
+ BIO_printf(bio_stdout,
+ "Inconsistent SSL_get0_alpn_selected() for client!\n");
+ goto err;
+ }
+
+ if (server_proto == NULL && server_proto_len != 0) {
+ BIO_printf(bio_stdout,
+ "Inconsistent SSL_get0_alpn_selected() for server!\n");
+ goto err;
+ }
+
if (client_proto_len != server_proto_len) {
BIO_printf(bio_stdout, "ALPN selected protocols differ!\n");
goto err;
#endif
fprintf(stderr, " -CApath arg - PEM format directory of CA's\n");
fprintf(stderr, " -CAfile arg - PEM format file of CA's\n");
- fprintf(stderr, " -cert arg - Server certificate file\n");
+ fprintf(stderr, " -s_cert arg - Server certificate file\n");
fprintf(stderr,
- " -key arg - Server key file (default: same as -cert)\n");
+ " -s_key arg - Server key file (default: same as -cert)\n");
fprintf(stderr, " -c_cert arg - Client certificate file\n");
fprintf(stderr,
" -c_key arg - Client key file (default: same as -c_cert)\n");
}
if (print_time) {
- if (bio_type != BIO_PAIR) {
+ if (bio_type == BIO_MEM) {
fprintf(stderr, "Using BIO pair (-bio_pair)\n");
bio_type = BIO_PAIR;
}
if (comp == COMP_ZLIB)
cm = COMP_zlib();
if (cm != NULL) {
- if (COMP_get_type(cm) != NID_undef) {
- if (SSL_COMP_add_compression_method(comp, cm) != 0) {
- fprintf(stderr, "Failed to add compression method\n");
- ERR_print_errors_fp(stderr);
- }
- } else {
- fprintf(stderr,
- "Warning: %s compression not supported\n",
- comp == COMP_ZLIB ? "zlib" : "unknown");
+ if (SSL_COMP_add_compression_method(comp, cm) != 0) {
+ fprintf(stderr, "Failed to add compression method\n");
ERR_print_errors_fp(stderr);
}
+ } else {
+ fprintf(stderr,
+ "Warning: %s compression not supported\n",
+ comp == COMP_ZLIB ? "zlib" : "unknown");
+ ERR_print_errors_fp(stderr);
}
ssl_comp_methods = SSL_COMP_get_compression_methods();
n = sk_SSL_COMP_num(ssl_comp_methods);
/* Use a fixed key so that we can decrypt the ticket. */
size = SSL_CTX_set_tlsext_ticket_keys(s_ctx, NULL, 0);
keys = OPENSSL_zalloc(size);
+ if (keys == NULL)
+ goto end;
SSL_CTX_set_tlsext_ticket_keys(s_ctx, keys, size);
OPENSSL_free(keys);
}
r = BIO_write(c_ssl_bio, cbuf, i);
if (r < 0) {
if (!BIO_should_retry(c_ssl_bio)) {
- fprintf(stderr, "ERROR in CLIENT\n");
+ fprintf(stderr, "ERROR in CLIENT (write)\n");
err_in_client = 1;
goto err;
}
r = BIO_read(c_ssl_bio, cbuf, sizeof(cbuf));
if (r < 0) {
if (!BIO_should_retry(c_ssl_bio)) {
- fprintf(stderr, "ERROR in CLIENT\n");
+ fprintf(stderr, "ERROR in CLIENT (read)\n");
err_in_client = 1;
goto err;
}
r = BIO_write(s_ssl_bio, sbuf, i);
if (r < 0) {
if (!BIO_should_retry(s_ssl_bio)) {
- fprintf(stderr, "ERROR in SERVER\n");
+ fprintf(stderr, "ERROR in SERVER (write)\n");
err_in_server = 1;
goto err;
}
r = BIO_read(s_ssl_bio, sbuf, sizeof(sbuf));
if (r < 0) {
if (!BIO_should_retry(s_ssl_bio)) {
- fprintf(stderr, "ERROR in SERVER\n");
+ fprintf(stderr, "ERROR in SERVER (read)\n");
err_in_server = 1;
goto err;
}
}
while (cw_num > 0 || cr_num > 0 || sw_num > 0 || sr_num > 0);
- if (verbose)
+ if (verbose) {
print_details(c_ssl, "DONE via TCP connect: ");
+
+ if (BIO_get_ktls_send(SSL_get_wbio(s_ssl))
+ && BIO_get_ktls_recv(SSL_get_rbio(s_ssl)))
+ BIO_printf(bio_stdout, "Server using Kernel TLS in both directions\n");
+ else if (BIO_get_ktls_send(SSL_get_wbio(s_ssl)))
+ BIO_printf(bio_stdout, "Server using Kernel TLS for sending\n");
+ else if (BIO_get_ktls_recv(SSL_get_rbio(s_ssl)))
+ BIO_printf(bio_stdout, "Server using Kernel TLS for receiving\n");
+
+ if (BIO_get_ktls_send(SSL_get_wbio(c_ssl))
+ && BIO_get_ktls_recv(SSL_get_rbio(c_ssl)))
+ BIO_printf(bio_stdout, "Client using Kernel TLS in both directions\n");
+ else if (BIO_get_ktls_send(SSL_get_wbio(c_ssl)))
+ BIO_printf(bio_stdout, "Client using Kernel TLS for sending\n");
+ else if (BIO_get_ktls_recv(SSL_get_rbio(c_ssl)))
+ BIO_printf(bio_stdout, "Client using Kernel TLS for receiving\n");
+ }
# ifndef OPENSSL_NO_NEXTPROTONEG
if (verify_npn(c_ssl, s_ssl) < 0)
goto end;