|
Packit Service |
4684c1 |
/*
|
|
Packit Service |
4684c1 |
* Copyright (C) 2000-2012 Free Software Foundation, Inc.
|
|
Packit Service |
4684c1 |
* Copyright (C) 2017 Red Hat, Inc.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* This file is part of GnuTLS.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* GnuTLS is free software: you can redistribute it and/or modify it
|
|
Packit Service |
4684c1 |
* under the terms of the GNU General Public License as published by
|
|
Packit Service |
4684c1 |
* the Free Software Foundation, either version 3 of the License, or
|
|
Packit Service |
4684c1 |
* (at your option) any later version.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* GnuTLS is distributed in the hope that it will be useful, but
|
|
Packit Service |
4684c1 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4684c1 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
4684c1 |
* General Public License for more details.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
4684c1 |
* along with this program. If not, see
|
|
Packit Service |
4684c1 |
* <https://www.gnu.org/licenses/>.
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <config.h>
|
|
Packit Service |
4684c1 |
#include <stdio.h>
|
|
Packit Service |
4684c1 |
#include <errno.h>
|
|
Packit Service |
4684c1 |
#include <stdlib.h>
|
|
Packit Service |
4684c1 |
#include <sys/types.h>
|
|
Packit Service |
4684c1 |
#include <string.h>
|
|
Packit Service |
4684c1 |
#include <gnutls/gnutls.h>
|
|
Packit Service |
4684c1 |
#include <sys/time.h>
|
|
Packit Service |
4684c1 |
#if HAVE_SYS_SOCKET_H
|
|
Packit Service |
4684c1 |
#include <sys/socket.h>
|
|
Packit Service |
4684c1 |
#elif HAVE_WS2TCPIP_H
|
|
Packit Service |
4684c1 |
#include <ws2tcpip.h>
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
#include <tests.h>
|
|
Packit Service |
4684c1 |
#include <common.h>
|
|
Packit Service |
4684c1 |
#include <ctype.h>
|
|
Packit Service |
4684c1 |
#include <cli-debug-args.h>
|
|
Packit Service |
4684c1 |
#include <socket.h>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* Gnulib portability files. */
|
|
Packit Service |
4684c1 |
#include "sockets.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void cmd_parser(int argc, char **argv);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* global stuff here */
|
|
Packit Service |
4684c1 |
int resume;
|
|
Packit Service |
4684c1 |
char *hostname = NULL;
|
|
Packit Service |
4684c1 |
int port;
|
|
Packit Service |
4684c1 |
int record_max_size;
|
|
Packit Service |
4684c1 |
int fingerprint;
|
|
Packit Service |
4684c1 |
static int debug = 0;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_srp_client_credentials_t srp_cred;
|
|
Packit Service |
4684c1 |
gnutls_anon_client_credentials_t anon_cred;
|
|
Packit Service |
4684c1 |
gnutls_certificate_credentials_t xcred;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* end of global stuff */
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
unsigned int verbose = 0;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
extern const char *ext_text;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void tls_log_func(int level, const char *str)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
fprintf(stderr, "|<%d>| %s", level, str);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
typedef test_code_t(*TEST_FUNC) (gnutls_session_t);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
typedef struct {
|
|
Packit Service |
4684c1 |
const char *test_name;
|
|
Packit Service |
4684c1 |
TEST_FUNC func;
|
|
Packit Service |
4684c1 |
const char *suc_str;
|
|
Packit Service |
4684c1 |
const char *fail_str;
|
|
Packit Service |
4684c1 |
const char *unsure_str;
|
|
Packit Service |
4684c1 |
unsigned https_only;
|
|
Packit Service |
4684c1 |
unsigned fatal_failure;
|
|
Packit Service |
4684c1 |
} TLS_TEST;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static const TLS_TEST tls_tests[] = {
|
|
Packit Service |
4684c1 |
{"whether the server accepts default record size (512 bytes)",
|
|
Packit Service |
4684c1 |
test_send_record, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"whether %ALLOW_SMALL_RECORDS is required",
|
|
Packit Service |
4684c1 |
test_send_record_with_allow_small_records, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
#ifdef ENABLE_SSL3
|
|
Packit Service |
4684c1 |
{"for SSL 3.0 (RFC6101) support", test_ssl3, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for SSL 3.0 with extensions", test_ssl3_with_extensions, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for SSL 3.0 with cipher suites not in SSL 3.0 spec",
|
|
Packit Service |
4684c1 |
test_ssl3_unknown_ciphersuites, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
/* The following tests will disable TLS 1.x if the server is
|
|
Packit Service |
4684c1 |
* buggy */
|
|
Packit Service |
4684c1 |
{"whether we need to disable TLS 1.2", test_tls_disable2, "no",
|
|
Packit Service |
4684c1 |
"yes", "dunno"},
|
|
Packit Service |
4684c1 |
{"whether we need to disable TLS 1.1", test_tls_disable1, "no",
|
|
Packit Service |
4684c1 |
"yes", "dunno"},
|
|
Packit Service |
4684c1 |
{"whether we need to disable TLS 1.0", test_tls_disable0, "no",
|
|
Packit Service |
4684c1 |
"yes", "dunno"},
|
|
Packit Service |
4684c1 |
/* The following test will disable extensions if the server
|
|
Packit Service |
4684c1 |
* is buggy */
|
|
Packit Service |
4684c1 |
{"whether %NO_EXTENSIONS is required", test_no_extensions, "no", "yes",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
{"whether %COMPAT is required", test_record_padding, "no", "yes",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
{"for TLS 1.0 (RFC2246) support", test_tls1, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for TLS 1.0 (RFC2246) support with TLS 1.0 record version", test_tls1_nossl3, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for TLS 1.1 (RFC4346) support", test_tls1_1, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"fallback from TLS 1.1 to", test_tls1_1_fallback, "TLS 1.0",
|
|
Packit Service |
4684c1 |
"failed",
|
|
Packit Service |
4684c1 |
"SSL 3.0"},
|
|
Packit Service |
4684c1 |
{"for TLS 1.2 (RFC5246) support", test_tls1_2, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for TLS 1.3 (RFC8446) support", test_tls1_3, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for known TLS or SSL protocols support", test_known_protocols, "yes", "no", "dunno", 0, 1},
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
{"TLS1.2 neg fallback from TLS 1.6 to", test_tls1_6_fallback, NULL,
|
|
Packit Service |
4684c1 |
"failed (server requires fallback dance)", "dunno"},
|
|
Packit Service |
4684c1 |
{"for inappropriate fallback (RFC7507) support", test_rfc7507, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for HTTPS server name", test_server, NULL, "failed", "not checked", 1},
|
|
Packit Service |
4684c1 |
{"for certificate information", test_certificate, NULL, "", ""},
|
|
Packit Service |
4684c1 |
{"for certificate chain order", test_chain_order, "sorted", "unsorted", "unknown"},
|
|
Packit Service |
4684c1 |
{"for trusted CAs", test_server_cas, NULL, "", ""},
|
|
Packit Service |
4684c1 |
{"for safe renegotiation (RFC5746) support", test_safe_renegotiation, "yes",
|
|
Packit Service |
4684c1 |
"no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for Safe renegotiation support (SCSV)",
|
|
Packit Service |
4684c1 |
test_safe_renegotiation_scsv,
|
|
Packit Service |
4684c1 |
"yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for encrypt-then-MAC (RFC7366) support", test_etm, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for ext master secret (RFC7627) support", test_ext_master_secret, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for heartbeat (RFC6520) support", test_heartbeat_extension, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for version rollback bug in RSA PMS", test_rsa_pms, "no", "yes",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
{"for version rollback bug in Client Hello", test_version_rollback,
|
|
Packit Service |
4684c1 |
"no", "yes", "dunno"},
|
|
Packit Service |
4684c1 |
{"whether the server ignores the RSA PMS version",
|
|
Packit Service |
4684c1 |
test_rsa_pms_version_check, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"whether small records (512 bytes) are tolerated on handshake",
|
|
Packit Service |
4684c1 |
test_small_records, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"whether cipher suites not in SSL 3.0 spec are accepted",
|
|
Packit Service |
4684c1 |
test_unknown_ciphersuites, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"whether a bogus TLS record version in the client hello is accepted", test_version_oob, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"whether the server understands TLS closure alerts", test_bye,
|
|
Packit Service |
4684c1 |
"yes", "no", "partially"},
|
|
Packit Service |
4684c1 |
/* the fact that is after the closure alert test does matter.
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
{"whether the server supports session resumption",
|
|
Packit Service |
4684c1 |
test_session_resume2, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
#ifdef ENABLE_ANON
|
|
Packit Service |
4684c1 |
{"for anonymous authentication support", test_anonymous, "yes",
|
|
Packit Service |
4684c1 |
"no",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
{"anonymous Diffie-Hellman group info", test_dhe_group, NULL, "N/A",
|
|
Packit Service |
4684c1 |
"N/A"},
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
{"for RSA key exchange support", test_rsa, "yes",
|
|
Packit Service |
4684c1 |
"no",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
{"for ephemeral Diffie-Hellman support", test_dhe, "yes", "no",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
{"for RFC7919 Diffie-Hellman support", test_rfc7919, "yes", "no",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
{"ephemeral Diffie-Hellman group info", test_dhe_group, NULL, "N/A",
|
|
Packit Service |
4684c1 |
"N/A"},
|
|
Packit Service |
4684c1 |
{"for ephemeral EC Diffie-Hellman support", test_ecdhe, "yes",
|
|
Packit Service |
4684c1 |
"no",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
#ifdef ENABLE_GOST
|
|
Packit Service |
4684c1 |
{"for VKO GOST-2012 (draft-smyshlyaev-tls12-gost-suites) support", test_vko_gost_12, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
{"for curve SECP256r1 (RFC4492)", test_ecdhe_secp256r1, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for curve SECP384r1 (RFC4492)", test_ecdhe_secp384r1, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for curve SECP521r1 (RFC4492)", test_ecdhe_secp521r1, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for curve X25519 (RFC8422)", test_ecdhe_x25519, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for AES-GCM cipher (RFC5288) support", test_aes_gcm, "yes", "no",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
{"for AES-CCM cipher (RFC6655) support", test_aes_ccm, "yes", "no",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
{"for AES-CCM-8 cipher (RFC6655) support", test_aes_ccm_8, "yes", "no",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
{"for AES-CBC cipher (RFC3268) support", test_aes, "yes", "no",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
{"for CAMELLIA-GCM cipher (RFC6367) support", test_camellia_gcm, "yes", "no",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
{"for CAMELLIA-CBC cipher (RFC5932) support", test_camellia_cbc, "yes", "no",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
{"for 3DES-CBC cipher (RFC2246) support", test_3des, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for ARCFOUR 128 cipher (RFC2246) support", test_arcfour, "yes", "no",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
{"for CHACHA20-POLY1305 cipher (RFC7905) support", test_chacha20, "yes", "no",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
#ifdef ENABLE_GOST
|
|
Packit Service |
4684c1 |
{"for GOST28147-CNT cipher (draft-smyshlyaev-tls12-gost-suites) support", test_gost_cnt, "yes", "no",
|
|
Packit Service |
4684c1 |
"dunno"},
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
{"for MD5 MAC support", test_md5, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for SHA1 MAC support", test_sha, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
{"for SHA256 MAC support", test_sha256, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
#ifdef ENABLE_GOST
|
|
Packit Service |
4684c1 |
{"for GOST28147-IMIT MAC (draft-smyshlyaev-tls12-gost-suites) support", test_gost_imit, "yes", "no", "dunno"},
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
{"for max record size (RFC6066) support", test_max_record_size, "yes",
|
|
Packit Service |
4684c1 |
"no", "dunno"},
|
|
Packit Service |
4684c1 |
#ifdef ENABLE_OCSP
|
|
Packit Service |
4684c1 |
{"for OCSP status response (RFC6066) support", test_ocsp_status, "yes",
|
|
Packit Service |
4684c1 |
"no", "dunno"},
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
{NULL, NULL, NULL, NULL, NULL}
|
|
Packit Service |
4684c1 |
};
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
const char *ip;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_session_t init_tls_session(const char *host)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
gnutls_session_t state = NULL;
|
|
Packit Service |
4684c1 |
gnutls_init(&state, GNUTLS_CLIENT);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
set_read_funcs(state);
|
|
Packit Service |
4684c1 |
if (host && is_ip(host) == 0)
|
|
Packit Service |
4684c1 |
gnutls_server_name_set(state, GNUTLS_NAME_DNS,
|
|
Packit Service |
4684c1 |
host, strlen(host));
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
return state;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
int do_handshake(socket_st * socket)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return 0; /* we do it locally */
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
int main(int argc, char **argv)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int ret;
|
|
Packit Service |
4684c1 |
int i;
|
|
Packit Service |
4684c1 |
char portname[6];
|
|
Packit Service |
4684c1 |
socket_st hd;
|
|
Packit Service |
4684c1 |
bool socket_opened = false;
|
|
Packit Service |
4684c1 |
char app_proto[32] = "";
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
cmd_parser(argc, argv);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#ifndef _WIN32
|
|
Packit Service |
4684c1 |
signal(SIGPIPE, SIG_IGN);
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
sockets_init();
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (gnutls_global_init() < 0) {
|
|
Packit Service |
4684c1 |
fprintf(stderr, "global state initialization error\n");
|
|
Packit Service |
4684c1 |
exit(1);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_global_set_log_function(tls_log_func);
|
|
Packit Service |
4684c1 |
gnutls_global_set_log_level(debug);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* get server name */
|
|
Packit Service |
4684c1 |
snprintf(portname, sizeof(portname), "%d", port);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* X509 stuff */
|
|
Packit Service |
4684c1 |
if (gnutls_certificate_allocate_credentials(&xcred) < 0) { /* space for 2 certificates */
|
|
Packit Service |
4684c1 |
fprintf(stderr, "memory error\n");
|
|
Packit Service |
4684c1 |
exit(1);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* SRP stuff */
|
|
Packit Service |
4684c1 |
#ifdef ENABLE_SRP
|
|
Packit Service |
4684c1 |
if (gnutls_srp_allocate_client_credentials(&srp_cred) < 0) {
|
|
Packit Service |
4684c1 |
fprintf(stderr, "memory error\n");
|
|
Packit Service |
4684c1 |
exit(1);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#ifdef ENABLE_ANON
|
|
Packit Service |
4684c1 |
/* ANON stuff */
|
|
Packit Service |
4684c1 |
if (gnutls_anon_allocate_client_credentials(&anon_cred) < 0) {
|
|
Packit Service |
4684c1 |
fprintf(stderr, "memory error\n");
|
|
Packit Service |
4684c1 |
exit(1);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (HAVE_OPT(STARTTLS_PROTO)) {
|
|
Packit Service |
4684c1 |
snprintf(app_proto, sizeof(app_proto), "%s", OPT_ARG(STARTTLS_PROTO));
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (app_proto[0] == 0) {
|
|
Packit Service |
4684c1 |
snprintf(app_proto, sizeof(app_proto), "%s", port_to_service(portname, "tcp"));
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
sockets_init();
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
printf("GnuTLS debug client %s\n", gnutls_check_version(NULL));
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
canonicalize_host(hostname, portname, sizeof(portname));
|
|
Packit Service |
4684c1 |
printf("Checking %s:%s\n", hostname, portname);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
for (i = 0;
|
|
Packit Service |
4684c1 |
tls_tests[i].test_name != NULL;
|
|
Packit Service |
4684c1 |
i++) {
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (strcmp(app_proto, "https") != 0 && tls_tests[i].https_only != 0) {
|
|
Packit Service |
4684c1 |
continue;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (!socket_opened) {
|
|
Packit Service |
4684c1 |
socket_open(&hd, hostname, portname, app_proto, SOCKET_FLAG_STARTTLS|SOCKET_FLAG_RAW, NULL, NULL);
|
|
Packit Service |
4684c1 |
hd.verbose = verbose;
|
|
Packit Service |
4684c1 |
socket_opened = true;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
ret = tls_tests[i].func(hd.session);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if ((ret != TEST_IGNORE && ret != TEST_IGNORE2) || verbose) {
|
|
Packit Service |
4684c1 |
printf("%58s...", tls_tests[i].test_name);
|
|
Packit Service |
4684c1 |
fflush(stdout);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (ret == TEST_SUCCEED) {
|
|
Packit Service |
4684c1 |
if (tls_tests[i].suc_str == NULL)
|
|
Packit Service |
4684c1 |
printf(" %s\n", ext_text);
|
|
Packit Service |
4684c1 |
else
|
|
Packit Service |
4684c1 |
printf(" %s\n", tls_tests[i].suc_str);
|
|
Packit Service |
4684c1 |
} else if (ret == TEST_FAILED)
|
|
Packit Service |
4684c1 |
printf(" %s\n", tls_tests[i].fail_str);
|
|
Packit Service |
4684c1 |
else if (ret == TEST_UNSURE)
|
|
Packit Service |
4684c1 |
printf(" %s\n", tls_tests[i].unsure_str);
|
|
Packit Service |
4684c1 |
else if ((ret == TEST_IGNORE || ret == TEST_IGNORE2) && verbose) {
|
|
Packit Service |
4684c1 |
printf(" skipped\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (ret != TEST_IGNORE) {
|
|
Packit Service |
4684c1 |
socket_bye(&hd, 1);
|
|
Packit Service |
4684c1 |
socket_opened = false;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (ret == TEST_FAILED && tls_tests[i].fatal_failure)
|
|
Packit Service |
4684c1 |
break;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#ifdef ENABLE_SRP
|
|
Packit Service |
4684c1 |
gnutls_srp_free_client_credentials(srp_cred);
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
gnutls_certificate_free_credentials(xcred);
|
|
Packit Service |
4684c1 |
#ifdef ENABLE_ANON
|
|
Packit Service |
4684c1 |
gnutls_anon_free_client_credentials(anon_cred);
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
gnutls_global_deinit();
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void cmd_parser(int argc, char **argv)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
char *rest = NULL;
|
|
Packit Service |
4684c1 |
static char lh[] = "localhost";
|
|
Packit Service |
4684c1 |
int optct = optionProcess(&gnutls_cli_debugOptions, argc, argv);
|
|
Packit Service |
4684c1 |
argc -= optct;
|
|
Packit Service |
4684c1 |
argv += optct;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (rest == NULL && argc > 0)
|
|
Packit Service |
4684c1 |
rest = argv[0];
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (HAVE_OPT(PORT))
|
|
Packit Service |
4684c1 |
port = OPT_VALUE_PORT;
|
|
Packit Service |
4684c1 |
else {
|
|
Packit Service |
4684c1 |
if (HAVE_OPT(STARTTLS_PROTO))
|
|
Packit Service |
4684c1 |
port = starttls_proto_to_port(OPT_ARG(STARTTLS_PROTO));
|
|
Packit Service |
4684c1 |
else
|
|
Packit Service |
4684c1 |
port = 443;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (rest == NULL)
|
|
Packit Service |
4684c1 |
hostname = lh;
|
|
Packit Service |
4684c1 |
else
|
|
Packit Service |
4684c1 |
hostname = rest;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (HAVE_OPT(DEBUG))
|
|
Packit Service |
4684c1 |
debug = OPT_VALUE_DEBUG;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (HAVE_OPT(VERBOSE))
|
|
Packit Service |
4684c1 |
verbose++;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
}
|