ctx->credentials);
if (ret != GNUTLS_E_SUCCESS) {
gnutls_deinit(ctx->session);
+ ctx->session = NULL;
return KNOT_ERROR;
}
if (alpn != NULL) {
ret = gnutls_alpn_set_protocols(ctx->session, alpn, alpn_size, 0);
if (ret != GNUTLS_E_SUCCESS) {
- gnutls_deinit(ctx->session);
+ tls_ctx_deinit(ctx);
return KNOT_NET_ECONNECT;
}
}
ret = gnutls_set_default_priority(ctx->session);
}
if (ret != GNUTLS_E_SUCCESS) {
- gnutls_deinit(ctx->session);
+ tls_ctx_deinit(ctx);
return KNOT_EINVAL;
}
ret = gnutls_server_name_set(ctx->session, GNUTLS_NAME_DNS, remote,
strlen(remote));
if (ret != GNUTLS_E_SUCCESS) {
- gnutls_deinit(ctx->session);
+ tls_ctx_deinit(ctx);
return KNOT_EINVAL;
}
}
gnutls_transport_set_fastopen(ctx->session, sockfd, (struct sockaddr *)addr,
sockaddr_len(addr), 0);
#else
- gnutls_deinit(ctx->session);
+ tls_ctx_deinit(ctx);
return KNOT_ENOTSUP;
#endif
} else {
if (ret != GNUTLS_E_SUCCESS && gnutls_error_is_fatal(ret) == 0) {
if (poll(&pfd, 1, 1000 * ctx->wait) != 1) {
WARN("TLS, peer took too long to respond");
- gnutls_deinit(ctx->session);
+ tls_ctx_deinit(ctx);
return KNOT_NET_ETIMEOUT;
}
}