Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use openconnect_open_https() and openconnect_close_https() better.
Use them unconditionally, without checking ->https_ssl first, and use them
in some places instead of open-coding the same thing.

This makes the code slightly more agnostic to the choice of SSL library.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed May 28, 2012
1 parent 1b6e58e commit 7616ee4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
3 changes: 2 additions & 1 deletion cstp.c
Expand Up @@ -378,7 +378,8 @@ int make_cstp_connection(struct openconnect_info *vpninfo)
{
int ret;

if (!vpninfo->https_ssl && (ret = openconnect_open_https(vpninfo)))
ret = openconnect_open_https(vpninfo);
if (ret)
return ret;

if (vpninfo->deflate) {
Expand Down
17 changes: 4 additions & 13 deletions http.c
Expand Up @@ -335,12 +335,8 @@ static int process_http_response(struct openconnect_info *vpninfo, int *result,
}
}

if (closeconn || vpninfo->no_http_keepalive) {
SSL_free(vpninfo->https_ssl);
vpninfo->https_ssl = NULL;
close(vpninfo->ssl_fd);
vpninfo->ssl_fd = -1;
}
if (closeconn || vpninfo->no_http_keepalive)
openconnect_close_https(vpninfo);

if (body)
body[done] = 0;
Expand Down Expand Up @@ -646,7 +642,7 @@ int openconnect_obtain_cookie(struct openconnect_info *vpninfo)
free(form_buf);
form_buf = NULL;
}
if (!vpninfo->https_ssl && openconnect_open_https(vpninfo)) {
if (openconnect_open_https(vpninfo)) {
vpn_progress(vpninfo, PRG_ERR,
_("Failed to open HTTPS connection to %s\n"),
vpninfo->hostname);
Expand Down Expand Up @@ -739,12 +735,7 @@ int openconnect_obtain_cookie(struct openconnect_info *vpninfo)
/* Kill the existing connection, and a new one will happen */
free(vpninfo->peer_addr);
vpninfo->peer_addr = NULL;
if (vpninfo->https_ssl) {
SSL_free(vpninfo->https_ssl);
vpninfo->https_ssl = NULL;
close(vpninfo->ssl_fd);
vpninfo->ssl_fd = -1;
}
openconnect_close_https(vpninfo);

for (opt = vpninfo->cookies; opt; opt = next) {
next = opt->next;
Expand Down
4 changes: 1 addition & 3 deletions library.c
Expand Up @@ -177,9 +177,7 @@ void openconnect_clear_cookie (struct openconnect_info *vpninfo)

void openconnect_reset_ssl (struct openconnect_info *vpninfo)
{
if (vpninfo->https_ssl) {
openconnect_close_https(vpninfo);
}
openconnect_close_https(vpninfo);
if (vpninfo->peer_addr) {
free(vpninfo->peer_addr);
vpninfo->peer_addr = NULL;
Expand Down

0 comments on commit 7616ee4

Please sign in to comment.