Fix tls_init bug

This commit is contained in:
Zhi Guan
2026-05-27 18:17:43 +08:00
parent 4df5b2c898
commit 711da7985a
3 changed files with 13 additions and 12 deletions

View File

@@ -122,6 +122,15 @@ bad:
return -1;
}
if (tls_ctx_init(&ctx, TLS_protocol_tlcp, TLS_client_mode) != 1) {
error_print();
return -1;
}
if (tls_ctx_set_cipher_suites(&ctx, client_ciphers, sizeof(client_ciphers)/sizeof(client_ciphers[0])) != 1) {
fprintf(stderr, "%s: context init error\n", prog);
goto end;
}
if (tls_socket_lib_init() != 1) {
error_print();
return -1;
@@ -145,12 +154,6 @@ bad:
goto end;
}
if (tls_ctx_init(&ctx, TLS_protocol_tlcp, TLS_client_mode) != 1
|| tls_ctx_set_cipher_suites(&ctx, client_ciphers, sizeof(client_ciphers)/sizeof(client_ciphers[0])) != 1) {
fprintf(stderr, "%s: context init error\n", prog);
goto end;
}
if (cacertfile) {
if (tls_ctx_set_ca_certificates(&ctx, cacertfile, TLS_DEFAULT_VERIFY_DEPTH) != 1) {
fprintf(stderr, "%s: context init error\n", prog);
@@ -199,9 +202,6 @@ bad:
fclose(outcertsfp);
}
// tls_shutdown(&conn);
// return 0;
if (get) {
struct timeval timeout;
timeout.tv_sec = TIMEOUT_SECONDS;