Update TLS -verbose options

This commit is contained in:
Zhi Guan
2026-06-12 14:23:56 +08:00
parent 8b586d4299
commit c56d7edfab
11 changed files with 403 additions and 280 deletions

View File

@@ -18,7 +18,7 @@
#include <gmssl/error.h>
static const char *options = "[-port num] -cert pem -key pem -pass str [-cacert pem]";
static const char *options = "[-port num] -cert pem -key pem -pass str [-cacert pem] [-verbose]";
static const char *help =
"Options\n"
@@ -35,6 +35,7 @@ static const char *help =
" -verify_depth num Certificate verification depth\n"
" -client_cert_optional Allow client send empty Certificate\n"
" -renegotiation_info Send renegotiation_info response when client supports RFC 5746\n"
" -verbose Print TLS handshake messages\n"
"\n"
#include "tls12_help.h"
"\n";
@@ -170,6 +171,7 @@ int tls12_server_main(int argc , char **argv)
int verify_depth = TLS_DEFAULT_VERIFY_DEPTH;
int client_cert_optional = 0;
int renegotiation_info = 0;
int verbose = 0;
TLS_CTX ctx;
TLS_CONNECT conn;
char buf[1600] = {0};
@@ -277,6 +279,8 @@ int tls12_server_main(int argc , char **argv)
client_cert_optional = 1;
} else if (!strcmp(*argv, "-renegotiation_info")) {
renegotiation_info = 1;
} else if (!strcmp(*argv, "-verbose")) {
verbose = 1;
} else {
fprintf(stderr, "%s: invalid option '%s'\n", prog, *argv);
return 1;
@@ -314,6 +318,10 @@ bad:
error_print();
return -1;
}
if (verbose && tls_ctx_set_verbose(&ctx, verbose) != 1) {
error_print();
goto end;
}
if (tls_ctx_set_cipher_suites(&ctx, cipher_suites, cipher_suites_cnt) != 1) {
fprintf(stderr, "%s: context init error\n", prog);