]> www.infradead.org Git - users/dwmw2/openconnect.git/log
users/dwmw2/openconnect.git
12 years agoFix GMP configure rule for Android build
David Woodhouse [Wed, 13 Mar 2013 00:33:25 +0000 (00:33 +0000)]
Fix GMP configure rule for Android build

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoImport translations from GNOME
David Woodhouse [Wed, 13 Mar 2013 00:01:12 +0000 (00:01 +0000)]
Import translations from GNOME

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoCheck for __ANDROID__ not ANDROID
David Woodhouse [Mon, 11 Mar 2013 14:08:11 +0000 (14:08 +0000)]
Check for __ANDROID__ not ANDROID

The latter doesn't appear to be set by the NDK.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoEnable shared libopenconnect for Android build
David Woodhouse [Mon, 11 Mar 2013 14:02:01 +0000 (14:02 +0000)]
Enable shared libopenconnect for Android build

We'll definitely want to use it from Java code for the authentication stage.
Not entirely sure yet how we'll invoke the main loop — perhaps by executing
the openconnect executable, but we *could* also invoke the main loop directly
from a Java process too. That might simplify the issue of protecting the
network sockets.

This ends up pulling libxml into libopenconnect.so, so the openconnect
executable gets it from there. Which isn't an ideal setup for the general
case but it's fairly convenient on Android.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoFix Android builds for x86 and mips
David Woodhouse [Mon, 11 Mar 2013 14:01:45 +0000 (14:01 +0000)]
Fix Android builds for x86 and mips

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoClean up CSD invocation for XML POST
David Woodhouse [Sun, 10 Mar 2013 21:01:53 +0000 (21:01 +0000)]
Clean up CSD invocation for XML POST

We don't use a CSD trojan to download; we *require* a local wrapper.

Theoretically we ought to be able to invoke a 'real' Cisco hostscan
tool. We ought to fix the command line arguments for that but let's keep
it simple for now. Just keep the command line exactly the same as for
wrapping the trojan, with an empty string where the name of the
downloaded file would be.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoFix redirect to CSD stub URL
David Woodhouse [Sun, 10 Mar 2013 21:01:18 +0000 (21:01 +0000)]
Fix redirect to CSD stub URL

I reverted too much.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoCSD stub URL is optional
David Woodhouse [Sun, 10 Mar 2013 19:00:04 +0000 (19:00 +0000)]
CSD stub URL is optional

The recent change in commit b6ef1c86b6d29684e5a24b62e19827afafec13ed ('Fix
CSD trojan download') was wrong; for the XML POST case we don't necessarily
get handed a trojan to download. We're expected to have a local 'wrapper'
script which will act like a locally-installed 'hostscan'.

The wait URL *is* required though.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoFix check for CSD
David Woodhouse [Sun, 10 Mar 2013 11:57:03 +0000 (11:57 +0000)]
Fix check for CSD

Antonio Borneo pointed out that we were checking (A && B && B). The third
one should have been vpninfo->csd_stuburl, not vpninfo->csd_waiturl again.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agogitignore: add cscope.*
Antonio Borneo [Sun, 10 Mar 2013 11:06:16 +0000 (19:06 +0800)]
gitignore: add cscope.*

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agogitignore: add files from "make"
Antonio Borneo [Sun, 10 Mar 2013 11:06:15 +0000 (19:06 +0800)]
gitignore: add files from "make"

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agogitignore: add files from ./configure
Antonio Borneo [Sun, 10 Mar 2013 11:06:14 +0000 (19:06 +0800)]
gitignore: add files from ./configure

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agogitignore: add autogen's files
Antonio Borneo [Sun, 10 Mar 2013 11:06:13 +0000 (19:06 +0800)]
gitignore: add autogen's files

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUniform coding style: don't use C99 // comments
Antonio Borneo [Sun, 10 Mar 2013 11:06:10 +0000 (19:06 +0800)]
Uniform coding style: don't use C99 // comments

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUniform coding style: no {} for single statement
Antonio Borneo [Sun, 10 Mar 2013 11:06:09 +0000 (19:06 +0800)]
Uniform coding style: no {} for single statement

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUniform coding style: conditional statement
Antonio Borneo [Sun, 10 Mar 2013 11:06:08 +0000 (19:06 +0800)]
Uniform coding style: conditional statement

Put single conditional statement in next line, not
with "if" or "else".

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUniform coding style: space and tabs
Antonio Borneo [Sun, 10 Mar 2013 11:06:07 +0000 (19:06 +0800)]
Uniform coding style: space and tabs

This patch just play with space and tabs, so
git diff -w
does not report anything.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUniform coding style: #if defined()
Antonio Borneo [Sun, 10 Mar 2013 11:06:06 +0000 (19:06 +0800)]
Uniform coding style: #if defined()

Current code mixes "defined()" and "defined ()"
Use Linux kernel choice so I can reuse kernel checkpatch.
sed -i 's/defined (/defined(/g'

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoImport translations from GNOME
David Woodhouse [Sat, 9 Mar 2013 22:45:56 +0000 (22:45 +0000)]
Import translations from GNOME

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoDon't emit the login banner and/or message when -q is used
John Morrissey [Sat, 9 Mar 2013 22:00:15 +0000 (17:00 -0500)]
Don't emit the login banner and/or message when -q is used

Signed-off-by: John Morrissey <jwm@horde.net>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoReduce GnuTLS library size for Android build
David Woodhouse [Fri, 8 Mar 2013 23:49:33 +0000 (23:49 +0000)]
Reduce GnuTLS library size for Android build

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoAdd missing newlines
David Woodhouse [Thu, 7 Mar 2013 17:38:09 +0000 (17:38 +0000)]
Add missing newlines

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoFix CSD trojan download
David Woodhouse [Thu, 7 Mar 2013 17:30:00 +0000 (17:30 +0000)]
Fix CSD trojan download

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoAndroid: Build GnuTLS from git
David Woodhouse [Wed, 6 Mar 2013 21:48:21 +0000 (21:48 +0000)]
Android: Build GnuTLS from git

This is fairly icky; I don't know how we're supposed to get the pkgconfig
Libs.private in our build, so I'm overriding $(GNUTLS_LIBS) manually.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoStop using deprecated gnutls_x509_crt type
David Woodhouse [Wed, 6 Mar 2013 21:37:40 +0000 (21:37 +0000)]
Stop using deprecated gnutls_x509_crt type

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoAvoid warning about verify_signed_data being unused
David Woodhouse [Wed, 6 Mar 2013 21:34:55 +0000 (21:34 +0000)]
Avoid warning about verify_signed_data being unused

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUse GNUTLS_CFLAGS when testing GnuTLS features too
David Woodhouse [Wed, 6 Mar 2013 21:13:33 +0000 (21:13 +0000)]
Use GNUTLS_CFLAGS when testing GnuTLS features too

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoAttempt to build GnuTLS for Android
David Woodhouse [Wed, 6 Mar 2013 17:58:10 +0000 (17:58 +0000)]
Attempt to build GnuTLS for Android

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoRevamp Android build infrastructure
David Woodhouse [Wed, 6 Mar 2013 11:12:44 +0000 (11:12 +0000)]
Revamp Android build infrastructure

The existing setup would only build as part of a full AOSP build, not as
a standalone application with the NDK. Fix that...

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoRemove unused variable 'ofs' in Android keystore_fetch()
David Woodhouse [Wed, 6 Mar 2013 11:12:01 +0000 (11:12 +0000)]
Remove unused variable 'ofs' in Android keystore_fetch()

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoMake it easier to avoid the broken OpenSSL DTLS check
David Woodhouse [Wed, 6 Mar 2013 10:08:27 +0000 (10:08 +0000)]
Make it easier to avoid the broken OpenSSL DTLS check

Now you just have to define NO_BROKEN_DTLS_CHECK instead of editing the
source code to remove the check.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUse OPENSSL_CFLAGS when testing OpenSSL features too
David Woodhouse [Wed, 6 Mar 2013 10:05:22 +0000 (10:05 +0000)]
Use OPENSSL_CFLAGS when testing OpenSSL features too

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUpdate translations from GNOME
David Woodhouse [Mon, 4 Mar 2013 21:03:40 +0000 (21:03 +0000)]
Update translations from GNOME

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agohttp: Don't leak the webvpn cookie in XML POST mode
Kevin Cernekee [Mon, 4 Mar 2013 02:20:51 +0000 (18:20 -0800)]
http: Don't leak the webvpn cookie in XML POST mode

XML POST mode introduces a new header in the <auth> response.  Squash it
so that people don't inadvertently post logs containing webvpn cookies.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoDestroy vpninfo->https_cred on failing to create it
David Woodhouse [Mon, 4 Mar 2013 00:45:21 +0000 (00:45 +0000)]
Destroy vpninfo->https_cred on failing to create it

If something like certificate setup went wrong, we'd return failure but
*not* destroy the gnutls_certificate_credentials_t that we were
attempting to set up. So a subsequent retry would see that it already
exists, assume it's *fine* and just go ahead and use it. Don't do that.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoHandle redirects in attempting simple auth GET too
David Woodhouse [Mon, 4 Mar 2013 00:28:08 +0000 (00:28 +0000)]
Handle redirects in attempting simple auth GET too

If the XML POST fails and we try a GET, we need to handle redirects for
that too. So re-use the same loop. Except the bit about not allowing local
redirects. Why do we do that for the XML POST case anyway?

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoDon't attempt to parse empty response from server
David Woodhouse [Mon, 4 Mar 2013 00:25:03 +0000 (00:25 +0000)]
Don't attempt to parse empty response from server

I couldn't trigger this until I hacked up stuff elsewhere to return
artificial failures, but still...

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoFix Android build with NDK
David Woodhouse [Sun, 3 Mar 2013 01:28:07 +0000 (01:28 +0000)]
Fix Android build with NDK

The NDK doesn't include keystore.h but that only has a few error numbers
so we can define those locally.

We also can't call socket_local_client() but that's only a simple socket()
and connect() call on a Unix socket anyway.

Also make keystore_strerror() return a const char *.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoCheck for __android_log_vprint in liblog.
Nikos Mavrogiannopoulos [Fri, 1 Mar 2013 23:14:19 +0000 (00:14 +0100)]
Check for __android_log_vprint in liblog.

Normally we'd use Android.mk but you can also build for Android using
Cerbero and the autohate build system instead.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUpdate translations from GNOME
David Woodhouse [Mon, 25 Feb 2013 11:56:03 +0000 (11:56 +0000)]
Update translations from GNOME

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoFix hostname canonicalisation to stop breaking certifcate checks
David Woodhouse [Fri, 22 Feb 2013 12:42:07 +0000 (12:42 +0000)]
Fix hostname canonicalisation to stop breaking certifcate checks

Commit b0b4b34f ('Canonicalise hostname during authentication if necessary')
replaces the hostname with a bare IP address if necessary, so that
reconnecting is guaranteed to get the *same* host from a round-robin and
comparing the SSL cert with its previous SHA1 fingerprint (which is how we
do it for two-stage connection for example from NetworkManager) is
guaranteed to work.

However, this breaks certificate auth when invoked in one-stage mode from
the command line to authenticate *and* actually make the connection. When
vpninfo->hostname is replaced with a bare IP address, that might not
actually be what's listed in the certificate's Subject or Altname fields.
So users have reported a certificate validation failure on *reconnecting*
to the server which was acceptable the first time round when we looked it
up by name.

So, don't actually replace vpninfo->hostname at all. Introduce a new field
vpninfo->unique_hostname which is returned by openconnect_get_hostname(),
and leave vpninfo->hostname as it was.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoLink directly to Nikos' server web site
David Woodhouse [Wed, 20 Feb 2013 19:33:00 +0000 (19:33 +0000)]
Link directly to Nikos' server web site

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUpdate changelog
David Woodhouse [Mon, 18 Feb 2013 01:07:41 +0000 (01:07 +0000)]
Update changelog

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoFix abuse of gnutls_realloc() causing memory leaks
David Woodhouse [Mon, 18 Feb 2013 01:04:44 +0000 (01:04 +0000)]
Fix abuse of gnutls_realloc() causing memory leaks

We need to free the original pointer, if gnutls_realloc() returns NULL.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoFix abuse of realloc() causing memory leaks
David Woodhouse [Mon, 18 Feb 2013 00:31:57 +0000 (00:31 +0000)]
Fix abuse of realloc() causing memory leaks

Implement a helper which actually *does* free the original pointer on
allocation failure, as I evidently always expected it to.

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=700805

Reported by: Niels Thykier <niels@thykier.net>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoFix GnuTLS 2.x build failure
David Woodhouse [Sun, 17 Feb 2013 22:18:01 +0000 (22:18 +0000)]
Fix GnuTLS 2.x build failure

We can move the algo calculation into a verify_signed_data() function. This
would have been a cleaner way to do it in the first place anyway.

Reported-by: Mike Miller <mtmiller@ieee.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoauth: stoken: Fix handling of "Next TOKENCODE" prompt
Kevin Cernekee [Sun, 17 Feb 2013 00:18:07 +0000 (16:18 -0800)]
auth: stoken: Fix handling of "Next TOKENCODE" prompt

This needs to allow for input elements named "answer" instead of
"password", and it needs to check form->message instead of the label
attribute for the "Next TOKENCODE" prompt.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agohttp: Fix redirect handling in auth form loop
Kevin Cernekee [Sun, 17 Feb 2013 00:18:06 +0000 (16:18 -0800)]
http: Fix redirect handling in auth form loop

The gateway may ask the user to fill out different forms that live at
different URLs, e.g.

    GET /+webvpn+/index.html
    (returns <form method="post" action="/+webvpn+/index.html"> and
     username/password form elements)
    POST /+webvpn+/index.html
    (returns <form method="post" action="/+webvpn+/login/challenge.html">
     and challenge/response form elements)
    POST /+webvpn+/login/challenge.html
    (returns <auth> node with valid cookie)

The refactored openconnect_obtain_cookie() loop tried to post the
challenge/response data to index.html, preventing successful login.  This
patch changes the logic so that it will honor the new "action" attribute
if present.

This probably does not affect XML POST mode, because XML POST <form> tags
do not seem to use attributes.

Reported-by: Fabian Jäger <fabian.jaeger@chungwasoft.com>
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoauth: Implement special handling of password fields on XML POST
Kevin Cernekee [Sun, 17 Feb 2013 00:18:05 +0000 (16:18 -0800)]
auth: Implement special handling of password fields on XML POST

The Cisco AnyConnect client exhibits some quirky behavior on fields
with certain names:

For "answer", "whichpin", and "new_password", the field is renamed to
"password" in the submission.

For "verify_pin" and "verify_password", the field is omitted entirely.
One might expect the client to perform a comparison to see if the first
password/PIN field matches the verify_* field, but in my testing, I didn't
actually see it doing so.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoauth: Implement special handling of <select> dropdowns on XML POST
Kevin Cernekee [Sun, 17 Feb 2013 00:18:04 +0000 (16:18 -0800)]
auth: Implement special handling of <select> dropdowns on XML POST

Experimentation with the Cisco AnyConnect client showed that the
following changes need to be made for compatibility:

1) If the "value" attribute is missing from the <option> node, use the
XML node content instead.  i.e. this should post as
"<dropdown>vpn</dropdown>":

    <select name="dropdown">
      <option>vpn</option>
    </select>

And this should post as "<dropdown>optname</dropdown>":

    <select name="dropdown">
      <option value="optname">vpn</option>
    </select>

2) If the name of the <select> node happens to be "group_list", put the
response in a special <group-select> node right under the <config-auth>
node, instead of putting it under the <auth> node.  (These strings are
hardcoded into the Cisco client.)

Reported-by: Fabian Jäger <fabian.jaeger@chungwasoft.com>
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoAdd server page to web pages
Nikos Mavrogiannopoulos [Wed, 13 Feb 2013 21:04:19 +0000 (22:04 +0100)]
Add server page to web pages

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoMerge retrospective 4.08 release into HEAD
David Woodhouse [Wed, 13 Feb 2013 21:31:03 +0000 (21:31 +0000)]
Merge retrospective 4.08 release into HEAD

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoTag version 4.08 v4.08
David Woodhouse [Wed, 13 Feb 2013 21:11:52 +0000 (21:11 +0000)]
Tag version 4.08

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUpdate translations
David Woodhouse [Wed, 13 Feb 2013 21:07:09 +0000 (21:07 +0000)]
Update translations

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUpdate changelog
David Woodhouse [Wed, 13 Feb 2013 21:04:06 +0000 (21:04 +0000)]
Update changelog

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoImpose minimum MTU of 1280 bytes.
David Woodhouse [Mon, 4 Feb 2013 16:01:51 +0000 (16:01 +0000)]
Impose minimum MTU of 1280 bytes.

Some people have seen extremely low pMTU values from the kernel. Not sure
why, but let's impose a lower limit for now.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
(cherry picked from commit b37161f6aa355b0e134de6b582a4c7838a4be07a)

12 years agoCanonicalise hostname during authentication if necessary
David Woodhouse [Mon, 4 Feb 2013 15:57:35 +0000 (15:57 +0000)]
Canonicalise hostname during authentication if necessary

Some people have round-robin servers, all addressed by the same hostname
but with different SSL certificates. Where we do the authentication (and
user-interactive approval of certificates) from a GUI via libopenconnect,
or with 'openconnect --authenticate', we end up being given the SHA1 on
the server's certificate and the non-interactive connection is going to
expect to see exactly that certificate. So if there is more than one
result in the original DNS lookup, *change* vpninfo->hostname to hold
the IP address that we actually connected to.

This means that the Host: header in what we send will be the numeric IP
address instead of the hostname, but that doesn't seem to hurt. It could
potentially, theoretically, break virtual hosts but I don't think that
kind of setup could ever existing in practice.

This also works only in the case where we're *not* connecting via a proxy.
We currently let the proxy do the DNS lookups *for* us, and we'd have to
do them locally and then ask the proxy for a connection by IP address
even for the *first* connection.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
(cherry picked from commit b0b4b34f5b3b397db1558c7c2c0b358db07c9964
 and subsequent fix commit 3e6ecfa511ab29ed83aac6fc3a96080fffdf1635)

12 years agohttp: Fix overflow on HTTP request buffers (CVE-2012-6128)
Kevin Cernekee [Sat, 27 Oct 2012 19:25:50 +0000 (12:25 -0700)]
http: Fix overflow on HTTP request buffers (CVE-2012-6128)

A malicious VPN gateway can send a very long hostname/path (for redirects)
or cookie list (in general), which OpenConnect will attempt to sprintf()
into a fixed length buffer.  Each HTTP server response line can add
roughly MAX_BUF_LEN (131072) bytes to the next OpenConnect HTTP request,
but the request buffer (buf) is capped at MAX_BUF_LEN bytes and is
allocated on the stack.

The result of passing a long "Location:" header looks like:

    Attempting to connect to server 127.0.0.1:443
    SSL negotiation with localhost
    Server certificate verify failed: self signed certificate in certificate chain
    Connected to HTTPS on localhost
    GET https://localhost/
    Got HTTP response: HTTP/1.0 301 Moved
    Ignoring unknown HTTP response line 'aaaaaaaaaaaaaaaaaa'
    SSL negotiation with localhost
    Server certificate verify failed: self signed certificate in certificate chain
    Connected to HTTPS on localhost
    *** buffer overflow detected ***: /scr/openconnect2/.libs/lt-openconnect terminated
    ======= Backtrace: =========
    /lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x5c)[0x7fd62729b82c]
    /lib/x86_64-linux-gnu/libc.so.6(+0x109700)[0x7fd62729a700]
    /lib/x86_64-linux-gnu/libc.so.6(+0x108b69)[0x7fd627299b69]
    /lib/x86_64-linux-gnu/libc.so.6(_IO_default_xsputn+0xdd)[0x7fd62720d13d]
    /lib/x86_64-linux-gnu/libc.so.6(_IO_vfprintf+0x1ae7)[0x7fd6271db4a7]
    /lib/x86_64-linux-gnu/libc.so.6(__vsprintf_chk+0x94)[0x7fd627299c04]
    /lib/x86_64-linux-gnu/libc.so.6(__sprintf_chk+0x7d)[0x7fd627299b4d]
    /scr/openconnect2/.libs/libopenconnect.so.2(openconnect_obtain_cookie+0xc0)[0x7fd62832d210]
    /scr/openconnect2/.libs/lt-openconnect[0x40413f]
    /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7fd6271b276d]
    /scr/openconnect2/.libs/lt-openconnect[0x404579]

The proposed fix is to use dynamically allocated buffers with overflow
checking.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
(cherry picked from commit 26f752c3dbf69227679fc6bebb4ae071aecec491)

12 years agoFix arguments to gnutls_pubkey_verify_data2
Nikos Mavrogiannopoulos [Wed, 13 Feb 2013 20:32:54 +0000 (20:32 +0000)]
Fix arguments to gnutls_pubkey_verify_data2

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUse gnutls_pubkey_verify_data2() where possible
David Woodhouse [Tue, 12 Feb 2013 23:59:34 +0000 (23:59 +0000)]
Use gnutls_pubkey_verify_data2() where possible

Unfortunately, gnutls_pubkey_verify_data() is deprecated. Which is a pain;
the 'threat model' that led to that deprecation doesn't apply here, and it
just means we have to jump through hoops to find the 'intended' algorithm
instead of letting it be inferred from the signature.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoDon't print "DTLS connected" when it isn't yet
David Woodhouse [Tue, 12 Feb 2013 14:24:58 +0000 (14:24 +0000)]
Don't print "DTLS connected" when it isn't yet

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoAdd build time and run time handling of recent OpenSSL brokenness
David Woodhouse [Tue, 12 Feb 2013 14:24:20 +0000 (14:24 +0000)]
Add build time and run time handling of recent OpenSSL brokenness

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoDocument recent OpenSSL brokenness, update GnuTLS/DTLS info
David Woodhouse [Tue, 12 Feb 2013 00:39:28 +0000 (00:39 +0000)]
Document recent OpenSSL brokenness, update GnuTLS/DTLS info

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoSwitch to using GnuTLS by default
David Woodhouse [Tue, 12 Feb 2013 00:29:25 +0000 (00:29 +0000)]
Switch to using GnuTLS by default

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoTag version 4.99 v4.99
David Woodhouse [Thu, 7 Feb 2013 01:10:27 +0000 (01:10 +0000)]
Tag version 4.99

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUpdate translations from Transifex
David Woodhouse [Thu, 7 Feb 2013 01:07:17 +0000 (01:07 +0000)]
Update translations from Transifex

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoDon't append port number to hostname when canonicalising
David Woodhouse [Tue, 5 Feb 2013 00:21:08 +0000 (00:21 +0000)]
Don't append port number to hostname when canonicalising

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoImpose minimum MTU of 1280 bytes.
David Woodhouse [Mon, 4 Feb 2013 16:01:51 +0000 (16:01 +0000)]
Impose minimum MTU of 1280 bytes.

Some people have seen extremely low pMTU values from the kernel. Not sure
why, but let's impose a lower limit for now.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoCanonicalise hostname during authentication if necessary
David Woodhouse [Mon, 4 Feb 2013 15:57:35 +0000 (15:57 +0000)]
Canonicalise hostname during authentication if necessary

Some people have round-robin servers, all addressed by the same hostname
but with different SSL certificates. Where we do the authentication (and
user-interactive approval of certificates) from a GUI via libopenconnect,
or with 'openconnect --authenticate', we end up being given the SHA1 on
the server's certificate and the non-interactive connection is going to
expect to see exactly that certificate. So if there is more than one
result in the original DNS lookup, *change* vpninfo->hostname to hold
the IP address that we actually connected to.

This means that the Host: header in what we send will be the numeric IP
address instead of the hostname, but that doesn't seem to hurt. It could
potentially, theoretically, break virtual hosts but I don't think that
kind of setup could ever existing in practice.

This also works only in the case where we're *not* connecting via a proxy.
We currently let the proxy do the DNS lookups *for* us, and we'd have to
do them locally and then ask the proxy for a connection by IP address
even for the *first* connection.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoImport translations from GNOME
David Woodhouse [Mon, 4 Feb 2013 15:40:04 +0000 (15:40 +0000)]
Import translations from GNOME

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoReinstate compatibility with test server hack
David Woodhouse [Mon, 4 Feb 2013 15:00:39 +0000 (15:00 +0000)]
Reinstate compatibility with test server hack

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoImport translations from GNOME
David Woodhouse [Fri, 18 Jan 2013 22:03:20 +0000 (22:03 +0000)]
Import translations from GNOME

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUpdate translations from Transifex
David Woodhouse [Sun, 30 Dec 2012 12:03:41 +0000 (12:03 +0000)]
Update translations from Transifex

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUpdate translations from Transifex
David Woodhouse [Tue, 18 Dec 2012 14:53:39 +0000 (14:53 +0000)]
Update translations from Transifex

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUpdate translations from GNOME
David Woodhouse [Tue, 18 Dec 2012 14:51:18 +0000 (14:51 +0000)]
Update translations from GNOME

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoImport translations from GNOME
David Woodhouse [Mon, 3 Dec 2012 13:46:57 +0000 (13:46 +0000)]
Import translations from GNOME

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUpdate translations from Transifex
David Woodhouse [Mon, 3 Dec 2012 11:19:27 +0000 (11:19 +0000)]
Update translations from Transifex

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agotun: Kill the tunnel script's process group
Kevin Cernekee [Wed, 14 Nov 2012 03:00:25 +0000 (19:00 -0800)]
tun: Kill the tunnel script's process group

When invoked with --script-tun, openconnect starts the tunnel script
via "/bin/sh -c 'SCRIPT'", then sends SIGHUP to the shell's PID when
shutting down.  However, non-interactive shells are not guaranteed to
send SIGHUP to any running jobs¹; indeed, the observed behavior on
Linux is that only the shell process receives SIGHUP, and the tunnel
script continues running after openconnect exits.

A quick fix is to set the child's pgid == pid, then send SIGHUP to the
entire process group when we want to shut down.

¹ http://www.gnu.org/software/bash/manual/html_node/Signals.html

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agotun: Don't call tunnel script on reconnect events
Kevin Cernekee [Wed, 14 Nov 2012 03:00:24 +0000 (19:00 -0800)]
tun: Don't call tunnel script on reconnect events

If --script-tun is used, the vpnc_script is not invoked for pre-init,
connect, or disconnect events.  However, it is invoked on reconnect, and
this may confuse the tunnel script.

Add an extra check to script_config_tun() to make the reconnect behavior
consistent with the behavior of other events.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUse -version-info arg to libtool on OpenBSD, not -version-number
David Woodhouse [Mon, 12 Nov 2012 23:38:04 +0000 (23:38 +0000)]
Use -version-info arg to libtool on OpenBSD, not -version-number

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoImport translations from GNOME
David Woodhouse [Mon, 12 Nov 2012 23:24:48 +0000 (23:24 +0000)]
Import translations from GNOME

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUse native libtool on OpenBSD
David Woodhouse [Thu, 8 Nov 2012 13:54:23 +0000 (13:54 +0000)]
Use native libtool on OpenBSD

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoInclude version.c from build dir in preference to source dir
David Woodhouse [Thu, 8 Nov 2012 13:31:23 +0000 (13:31 +0000)]
Include version.c from build dir in preference to source dir

This should fix out-of-source-tree builds from a tarball, which
otherwise would use the autogenerated $(objdir)/version.c for building
the library, but the pre-packaged $(srcdir)/version.c for the
executable. This is because the latter was included directly from main.c
by #include "version.c". By changing to #include <main.c> instead, we get
to use the new auto-generated one instead if anything's been changed.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoHandle libintl needing libiconv (for OpenBSD 5.2)
David Woodhouse [Wed, 7 Nov 2012 20:48:27 +0000 (20:48 +0000)]
Handle libintl needing libiconv (for OpenBSD 5.2)

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoImport translations from GNOME
David Woodhouse [Wed, 7 Nov 2012 13:22:43 +0000 (13:22 +0000)]
Import translations from GNOME

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoAvoid incorrect compiler warning about optlen being used uninitialised
David Woodhouse [Tue, 6 Nov 2012 14:15:19 +0000 (14:15 +0000)]
Avoid incorrect compiler warning about optlen being used uninitialised

GCC 3.4.3 on Solaris 11.1 complains:
main.c:348: warning: 'optlen' might be used uninitialized in this function

It's wrong, and it's obviously wrong. But shut it up anyway.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoUse libsocket and libnsl as necessary on Solaris
David Woodhouse [Tue, 6 Nov 2012 14:14:33 +0000 (14:14 +0000)]
Use libsocket and libnsl as necessary on Solaris

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoFix library versioning
David Woodhouse [Mon, 5 Nov 2012 21:08:36 +0000 (21:08 +0000)]
Fix library versioning

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoImport translations from GNOME
David Woodhouse [Mon, 5 Nov 2012 20:55:44 +0000 (20:55 +0000)]
Import translations from GNOME

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoFix missing newlines on more messages
David Woodhouse [Mon, 5 Nov 2012 20:55:33 +0000 (20:55 +0000)]
Fix missing newlines on more messages

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
12 years agoMerge branch 'xmlpost-v2' of git://github.com/cernekee/openconnect
David Woodhouse [Mon, 5 Nov 2012 21:00:28 +0000 (21:00 +0000)]
Merge branch 'xmlpost-v2' of git://github.com/cernekee/openconnect

12 years agowww: Update changelog
Kevin Cernekee [Sun, 28 Oct 2012 17:32:11 +0000 (10:32 -0700)]
www: Update changelog

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
12 years agowww: Use a more "stable" URL for the libstoken homepage
Kevin Cernekee [Sun, 28 Oct 2012 17:29:41 +0000 (10:29 -0700)]
www: Use a more "stable" URL for the libstoken homepage

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
12 years agoDocument new --os option
Kevin Cernekee [Sun, 28 Oct 2012 17:28:25 +0000 (10:28 -0700)]
Document new --os option

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
12 years agostoken: Fix CSD/stoken interaction
Kevin Cernekee [Sun, 28 Oct 2012 07:41:32 +0000 (00:41 -0700)]
stoken: Fix CSD/stoken interaction

When using CSD, the auth form could be parsed more than once per
connection.  Change the accounting so that stoken_tries only gets
incremented if a tokencode is actually generated.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
12 years agoFix a couple of valgrind warnings
Kevin Cernekee [Sun, 28 Oct 2012 07:01:27 +0000 (00:01 -0700)]
Fix a couple of valgrind warnings

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
12 years agohttp: Rewrite openconnect_obtain_cookie() loop
Kevin Cernekee [Sat, 27 Oct 2012 22:21:09 +0000 (15:21 -0700)]
http: Rewrite openconnect_obtain_cookie() loop

First try XML POST, then fall back to the old method if that breaks.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
12 years agocsd: Export some useful environment variables
Kevin Cernekee [Sun, 28 Oct 2012 04:42:25 +0000 (21:42 -0700)]
csd: Export some useful environment variables

CSD_HOSTNAME is a known-valid hostname on which (hopefully) our script
won't have to perform too much input validation to know it's safe.

CSD_TOKEN is passed in as the "sdesktop" cookie from host scan.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
12 years agocsd: Don't return from run_csd_script() in the forked process
Kevin Cernekee [Sun, 28 Oct 2012 04:36:11 +0000 (21:36 -0700)]
csd: Don't return from run_csd_script() in the forked process

If something in the CSD child process fails, we want it to exit.  We
do not want it to return to openconnect_obtain_cookie() and cause two
instances of the latter function to run in parallel.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
12 years agohttp: Record the last redirection type
Kevin Cernekee [Sun, 28 Oct 2012 04:14:07 +0000 (21:14 -0700)]
http: Record the last redirection type

The AnyConnect client uses the redirection type (new host, or just a
new URL on the same host) to figure out whether to use XML POST or
the old urlencoded scheme.  Preserve this information for future use.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>