144 Commits

Author SHA1 Message Date
Nick Mathewson
2e2d18bcd3 Merge pull request #170 from azat/https-client-retries
https-client: add -retries argument, for connection retries
2014-10-09 11:29:17 -04:00
Joakim Soderberg
5c7282f7a5 Fix compilation for older OpenSSL versions.
For instance OpenSSL 0.9.7 does not have SSL_set_tlsext_host_name.

Also add the missing EVENT__DISABLE_SAMPLES CMake option.
2014-09-24 13:46:09 +02:00
Azat Khuzhin
d9da844369 https-client: add -retries argument, for connection retries
Using evhttp_connection_set_retries() API.
2014-09-21 23:48:07 +04:00
Nick Mathewson
8bf769c47a Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	sample/http-server.c
2014-08-29 14:32:10 -04:00
Nick Mathewson
6466e88ac1 Use FindClose for handle from FindFirstFile in http-server.c
Noted by Miles Chan as issue #145
2014-08-29 14:31:07 -04:00
Mike Frysinger
0c492b33f9 add a --disable-samples configure flag
For people building & installing libevent in a distro, building all these
sample apps are not useful.  Add a flag to turn them off.
2014-06-13 17:19:50 -04:00
Nick Mathewson
6d72bdca01 Make http-server.c output into good html5 2014-05-30 13:53:27 -04:00
Nick Mathewson
462e6b609b add a cast to https-client.c 2014-03-12 12:45:41 -04:00
Joakim Soderberg
e212c5486d Check for OSX when checking for clang. 2014-01-22 13:19:49 +01:00
Joakim Soderberg
d7be788780 Fix https-client compilation on Windows.
ssize_t is not defined. But using ssize_t for s in this context makes no
sense, since fread returns size_t.
2014-01-22 11:15:17 +01:00
Nick Mathewson
4cb44fdf56 Merge remote-tracking branch 'joakimsoderberg/new_cmake'
Conflicts:
	sample/https-client.c
2014-01-21 14:26:01 -05:00
Joakim Söderberg
8b40a5b08f Check if we're on OSX before disabling deprecation in le-proxy 2014-01-21 11:35:21 +01:00
Joakim Söderberg
4e1439588f Change all uses of WIN32 to _WIN32 2014-01-21 11:30:27 +01:00
Nick Mathewson
88ecda3bbb Fix a couple of "#ifdef WIN32" instances 2013-12-24 14:37:30 -05:00
Nick Mathewson
d1976f8ec4 Sample HTTPS Client: Set hostname for SNI extension (by f69m)
Patch from f69m on SourceForge
2013-12-24 14:05:44 -05:00
Nick Mathewson
90786eb073 Small tweaks to https-client.c 2013-12-24 12:59:36 -05:00
Nick Mathewson
2fbc3b148b Merge remote-tracking branch 'resetius/https' 2013-12-24 12:45:22 -05:00
Joakim Soderberg
0ef1d04e44 Get rid of unknown pragma warnings. 2013-12-17 14:32:07 +01:00
Joakim Söderberg
69c3516be6 Get rid of deprecation warnings for OpenSSL on OSX 10.7+ 2013-12-17 13:28:23 +01:00
Joakim Soderberg
19222e5247 Added some GCC specific options.
- Added sample applications.
- Fixed the https-client to work on Windows kind of (No cert validation).
2013-12-13 16:27:10 +00:00
Azat Khuzhin
6171e1c294 sample: drop uri_root from base_url in http-server.
By default there is "0.0.0.0", and this address will work only from
the same machine, and besides there is no need in uri_root in base_url,
because it will be added automatically by browser.
2013-08-13 18:19:50 +04:00
Nick Mathewson
44b2491bcd sample/le-proxy: Fail more gracefully if opening listener fails 2013-08-06 19:23:36 -04:00
Nick Mathewson
eb6b0c1f90 Merge branch '21_evdns_disable_when_inactive' 2013-04-25 10:47:16 -04:00
Azat Khuzhin
6b7fa620e8 evdns: New flag to make evdns not prevent the event loop from exiting
Here is the brief description of problem:
When you are use evdns to resolve domains to IP adresses (see
./sample/dns-example) you loop never returns from event_base_dispatch(),
and because of this the program will never terminated.

Because existing programs may be depending on the old behavior, we
only apply the fix when evdns_base_new() is created with a new flag -
EVDNS_BASE_DISABLE_WHEN_INACTIVE.

 (Commit message edited by Nick while squashing the branch.)
2013-04-25 10:43:12 -04:00
Alexey Ozeritsky
29af65ebfc https-client: code cleanup 2013-04-14 15:41:44 +04:00
Alexey Ozeritsky
902bf21e58 Merge branch 'master' of https://github.com/libevent/libevent into https 2013-04-14 15:12:22 +04:00
Nick Mathewson
95acdaa353 Another tweak to https-client.c 2013-04-10 17:56:54 -04:00
Nick Mathewson
8a90a850fc Remove http_struct.h usage in sample/https-client.c 2013-04-10 13:53:44 -04:00
Alexey Ozeritsky
c5887f73b7 POST supported, args supported 2013-03-11 18:31:19 +04:00
Patrick Pelletier
4db9da6bbf pull in wildcard matching code from cURL
Now, https-client accepts both:

https://ip.appspot.com/ (matching wildcard certificate)
https://github.com/     (matching non-wildcard certificate)

but still rejects

https://www.kegel.com/  (non-matching wildcard certificate)

which should match the behavior of these sites in a web browser.
2013-02-27 21:22:03 -08:00
Patrick Pelletier
6021cb5027 avoid sign mismatch warning in openssl_hostname_validation.c
sample/openssl_hostname_validation.c: In function 'matches_common_name':
sample/openssl_hostname_validation.c:80: warning: comparison between signed and unsigned integer expressions
sample/openssl_hostname_validation.c: In function 'matches_subject_alternative_name':
sample/openssl_hostname_validation.c:124: warning: comparison between signed and unsigned integer expressions
2013-02-27 21:22:03 -08:00
Patrick Pelletier
64d9f161fe use iSECPartners code to validate hostname in certificate
The problem is that if you go to a website whose certificate does not
match its hostname, it should fail.  Try this in a web browser for
https://www.kegel.com/ for example.  Your web browser will say the
certificate is for *.pair.com, not for www.kegel.com, and won't let
you visit it without clicking through a bunch of scary warnings.

However, prior to this commit, https-client was happy to fetch
https://www.kegel.com/ without complaining.  That is bad.  Now, with
this commit, it will properly complain, which is good:

pelletier@chives:~/src/libevent/sample$ ./https-client https://www.kegel.com/
Got 'MatchNotFound' for hostname 'www.kegel.com' and certificate:
/C=US/postalCode=15203/ST=Pennsylvania/L=Pittsburgh/street=Suite 210/street=2403 Sidney Street/O=pair Networks, Inc./OU=Provided by pair Networks, Inc./OU=PairWildcardSSL $250,000/CN=*.pair.com
some request failed - no idea which one though!
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
ppelletier@chives:~/src/libevent/sample$

It will still succeed for sites with an exactly-matching certificate,
such as https://github.com/ and that is also good!

However, the problem is that the iSECPartners code doesn't handle
wildcards, which means we reject https://ip.appspot.com/ even though
it is perfectly legitimate, because we don't understand the wildcard:

ppelletier@chives:~/src/libevent/sample$ ./https-client https://ip.appspot.com/
Got 'MatchNotFound' for hostname 'ip.appspot.com' and certificate:
/C=US/ST=California/L=Mountain View/O=Google Inc/CN=*.appspot.com
some request failed - no idea which one though!
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
ppelletier@chives:~/src/libevent/sample$

So, we need to fix this.  In other words, "to be continued..."
2013-02-27 21:22:03 -08:00
Patrick Pelletier
aacd674c94 use Debian's default root certificate location
as suggested here:
http://archives.seul.org/libevent/users/Feb-2013/msg00034.html

although curl's acinclude.m4 reveals many other possibilities:

dnl /etc/ssl/certs/ca-certificates.crt Debian systems
dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
dnl /usr/local/share/certs/ca-root.crt FreeBSD
dnl /etc/ssl/cert.pem OpenBSD
dnl /etc/ssl/certs/ (ca path) SUSE

And none of these cover Windows :(
2013-02-27 21:22:03 -08:00
Patrick Pelletier
5754d96a6e better handling of OpenSSL errors 2013-02-27 21:22:03 -08:00
Patrick Pelletier
42d7441ac4 https-client was putting newlines at 256-byte boundaries
presumably this was meant to put a ">" before every line, but that
isn't what it does, since evbuffer_remove is simply returning
fixed-size chunks.  So, when retrieving a document of more than 256
bytes (e. g. any nontrivial document), we got "> " and newlines thrown
in at very arbitrary places.
2013-02-27 21:22:03 -08:00
Patrick Pelletier
bf31fa5d30 use ${OPENSSL_LIBS} instead of -lssl -lcrypto
This made the difference between segfaulting and not segfaulting for
me when I run https-client, when I've built libevent using an OpenSSL
in a non-standard location.

In the same spirit as 1d9d5110a4aebf5833f6fd78bd0252affde0f4d0 and
d70af27d0152d0a87a25127faf215604beb8ffe0.
2013-02-27 21:22:03 -08:00
Catalin Patulea
be46c99b89 Add sample/https-client.c, an example of stacking evhttp as a client on top of bufferevent_ssl.
Signed-off-by: Catalin Patulea <catalinp@google.com>
2013-02-27 16:06:56 -08:00
Nick Mathewson
f324b1dffc Merge remote-tracking branch 'origin/patches-2.0' 2013-01-22 17:10:07 +00:00
Gyepi Sam
c322c2077e Fix a mistake in evbuffer_remove() arguments in example http server code
(commit message by nickm)
2013-01-22 16:59:07 +00:00
Sebastian Hahn
9e8cdf3d65 Fix comment to refer to sample/include.am correctly 2012-12-23 18:41:00 +01:00
Nick Mathewson
2e6a985003 Merge remote-tracking branch 'github/20_win64_compilation' into 21_win64_compilation
Conflicts:
	event.c
	http.c
	sample/event-read-fifo.c
	test/regress_bufferevent.c
2012-11-01 18:12:07 -04:00
Nick Mathewson
6810908a5f Fix some warnings found cross-compiling with mingw32 2012-11-01 18:05:27 -04:00
Nick Mathewson
94866c2763 Compile without warnings on mingw64
This is mostly a matter of catching cases where we were still
assuming that evutil_socket_t could be used as an int.
2012-11-01 17:56:06 -04:00
Nick Mathewson
6cdfeebebc Rename subordinate Makefile.ams to include.am 2012-08-28 16:01:14 -04:00
Nick Mathewson
7092f3b677 Switch to non-recursive makefiles
This approach should let Make work better, let libevent build faster
(especially when using a parallelized build), and basically make the
Makefiles easier to maintain.

See http://miller.emu.id.au/pmiller/books/rmch/ for more info on why
you'd want to do this.

This is due to an idea from Zack Weinberg; the patch is my own.
2012-08-28 15:58:18 -04:00
Nick Mathewson
4b70286ef1 Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	ChangeLog
	README
	evdns.c
	sample/dns-example.c
2012-05-02 17:12:23 -04:00
Nick Mathewson
6610fa5a27 dns-example.c can now take a resolv.conf file on the commandline 2012-05-01 17:07:50 -04:00
Nick Mathewson
2711cda300 Split long lists in Makefile.am into one-item-per-line 2012-04-20 12:14:20 -04:00
Mark Ellzey
041ca00c75 Add a new libevent_global_shutdown() to free all globals before exiting.
Mark Ellzey added a function libevent_shutdown() which calls a set of
private functions:

       * event_free_globals()
       * event_free_debug_globals()
       * event_free_debug_globals_locks()
       * event_free_evsig_globals()
       * evsig_free_globals()
       * evsig_free_globals_locks()
       * evutil_free_globals()
       * evutil_free_secure_rng_globals()
       * evutil_free_secure_rng_globals_lock()

Nick tweaked this libevent global shutdown code:

  - rename the function to emphasize that it's for global resources
  - write more in the doxygen
  - make function brace style consistent
  - add a missing void in a function definition.
2012-03-22 11:57:04 -04:00
Nick Mathewson
24dab0b359 event-read-fifo: Use EV_PERSIST appropriately 2012-03-19 14:39:06 -04:00