Commit c0246ffe authored by Kevin Cernekee's avatar Kevin Cernekee

dtls: Free OpenSSL contexts when the library instance is freed

Per valgrind these leaked about 1kB.
Signed-off-by: default avatarKevin Cernekee <cernekee@gmail.com>
parent b37e007f
......@@ -305,6 +305,13 @@ int dtls_try_handshake(struct openconnect_info *vpninfo)
return -EINVAL;
}
void dtls_shutdown(struct openconnect_info *vpninfo)
{
dtls_close(vpninfo);
SSL_CTX_free(vpninfo->dtls_ctx);
SSL_SESSION_free(vpninfo->dtls_session);
}
#elif defined(DTLS_GNUTLS)
#include <gnutls/dtls.h>
......@@ -444,6 +451,11 @@ int dtls_try_handshake(struct openconnect_info *vpninfo)
time(&vpninfo->new_dtls_started);
return -EINVAL;
}
void dtls_shutdown(struct openconnect_info *vpninfo)
{
dtls_close(vpninfo);
}
#endif
int connect_dtls_socket(struct openconnect_info *vpninfo)
......@@ -889,4 +901,8 @@ int dtls_reconnect(struct openconnect_info *vpninfo)
void dtls_close(struct openconnect_info *vpninfo)
{
}
void dtls_shutdown(struct openconnect_info *vpninfo)
{
}
#endif
......@@ -137,7 +137,7 @@ static void free_optlist(struct oc_vpn_option *opt)
void openconnect_vpninfo_free(struct openconnect_info *vpninfo)
{
openconnect_close_https(vpninfo, 1);
dtls_close(vpninfo);
dtls_shutdown(vpninfo);
if (vpninfo->cmd_fd_write != -1) {
close(vpninfo->cmd_fd);
close(vpninfo->cmd_fd_write);
......
......@@ -464,6 +464,7 @@ int dtls_mainloop(struct openconnect_info *vpninfo, int *timeout);
int dtls_try_handshake(struct openconnect_info *vpninfo);
int connect_dtls_socket(struct openconnect_info *vpninfo);
void dtls_close(struct openconnect_info *vpninfo);
void dtls_shutdown(struct openconnect_info *vpninfo);
int dtls_reconnect(struct openconnect_info *vpninfo);
/* cstp.c */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment