Move fetch_config() invocation out to allow it to be used in XML POST mode

This means adding profile_url and profile_sha1 fields to the vpninfo, then
using them from fetch_config(). Move the comparison of the existing SHA1
(if any) into fetch_config() while we're at it.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Process XML POST response to find profile URL and download it

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Import translations from GNOME

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Resync translations with sources

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Don't fetch XML profile unless ->write_new_config() is set

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Make proxy_{read,write,gets}() return the same as the SSL methods

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Use callbacks in vpninfo for ssl_{read,write,gets} methods

Slightly cleaner, and will allow us to use process_http_response() for
unencrypted communication with a proxy too.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Use ssl_{read,write,gets} methods for unencrypted ("proxy") access too

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Use process_http_response() for proxy handling

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Propagate openconnect_open_https() return value

Don't convert this into -EINVAL, particularly in do_https_request(), because
that causes us to make a second attempt to connect in non-XMLPOST mode. When
the failure happened on the *connection*, that's pointless.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
First pass at adding proxy auth support

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
http: Check asprintf() return value

This fixes the following warning:

      CC       libopenconnect_la-http.lo
    http.c: In function 'openconnect_obtain_cookie':
    http.c:1270:13: warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result [-Wunused-result]
         asprintf(&vpninfo->profile_url, "%s%s", bu, fu);
                 ^

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Initial NTLM auth support

This only works with the ntlm_auth helper. Implementing NTLM manually is
left as an exercise for the user.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Clean up ntlm_helper_fd on proxy done

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Print when attempting NTLM auth

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Rename buf_append() in cstp.c to cbuf_append()

We're about to make it use the nicer buf_append() from http.c but let's
make the simple change to avoid the conflict first...

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Make buf_append() from http.c visible elsewhere

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Add printf format attribute to buf_append()

Fix the one (harmless) warning it generates in base64 encoding.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Use generic buf_append() in start_cstp_connection()

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Add FIXME in start_cstp_connection()

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>