Commit Graph
75 Commits
Author SHA1 Message Date
Marek Safar 92ff3c372d [system.net.http] Make SendAsync state free to handle recursive calls. Fixes #22724 2014-09-08 11:48:51 +02:00
Alexander Köplinger 48e112d652 [Cleanup] Removed TARGET_JVM
It was once part of a special Java target profile, but this is no longer used today.
2014-08-08 03:28:34 +02:00
Martin Baulig f462bcc944 [Http]: Only recycle ServicePoints from the idle timer (fixes #19823).
Thanks a lot for Martin Potter to find and report the race condition
which was causing the problem.

ServicePointManager.RecycleServicePoints() was a left-over from the
old times when we didn't have an idle-timer based approach.
2014-06-10 19:21:32 +02:00
Marek Habersack 34fb07d05f Include support for SSL/TLS right in System when building for the MONODROID profile
This patch builds upon commit 96a8500795 which placed parts of Mono.Security
responsible for dealing with SSL/TLS certificates for the purpose of certificate verification. The code enables
validation of the certifcates even if the user does not provide their own validation callback. The changes as related to
the original commit are few, basically consisting of enabling the same code used by MonoTouch in the MonoDroid context with
the only actual code change being the certificate validation bit mentioned above.

Since the change involves adding a subset of Mono.Security files to the monodroid version of System.dll, it is
also necessary to remove Mono.Android's dependence on Mono.Security.dll. The reason is that the code in AndroidPlatform
which looks up TLS support methods in Mono.Android.dll would use a type (X509CertificateCollection) that is now part of
System.dll but is *also* in Mono.Security.dll referenced by Mono.Android.dll and therefore the lookup would fail since
we'd have two distinct types from the reflection point of view.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=18962
2014-04-25 21:39:53 +02:00
Sebastien Pouliot 43fcd744d0 [SSL/TLS] Expose Client/Server callbacks that can be used to select/reorder SSL/TLS cipher suites used (for client or server) and add unit tests for them [#16327] 2014-02-19 08:51:51 -05:00
Martin Baulig c6a70a9586 Rewrite and fix the web stack's connection reuse and idle logic.
* ServicePoint now uses an idle timer to close idle connections.

* WebConnectionGroup has been mostly rewritten to use a linked
  list of open connections and their idle times.

  This fixes both the problem that we were leaking sockets and
  that we were not reusing existing connections.

* ServicePoint now correctly keeps track of the number of open
  connections.

* ServicePointManager now uses the correct default idle time
  of 100 seconds (previously 15 minutes).

* WebConnection uses the new WebConnectionGroup's busy logic
  to correctly flag connections as busy / reusable.
2014-02-13 14:17:14 +01:00
Paolo Molaro cc7b7992ff Reduce contention and unnecessary checks at each lookup, part of xambug #14644. 2013-11-05 17:37:08 +01:00
Sebastien Pouliot 96a8500795 Allow the MONOTOUCH targetr to build its SSL/TLS support right inside System.dll and remove code duplication and non-required code paths. 2013-07-01 16:21:04 -04:00
Martin Baulig db06719d2a [System]: Make ServicePointManager hash on the proxy as well as uri and use_connect.
This fixes #12640.
2013-06-21 14:25:51 +02:00
Atsushi Eno 76af46a676 Fix monodroid build. 2013-02-27 17:51:56 +09:00
Marek Safar 93c35ffe14 Fix more compiler warnings 2013-02-26 10:37:02 +01:00
Marek Safar 5aeeb9cf7b Fix few warnings 2013-02-25 19:10:09 +01:00
Marek Safar 0647a5d16b Remove duplicated files from system.dll (saves about 100kb) 2013-02-25 19:10:09 +01:00
Rodrigo Kumpera 5007c14d62 Kill the MOONLIGHT define in System. 2013-02-11 13:01:11 -05:00
Atsushi Eno 740d826912 fix mobile build (from 6b4c3f0). 2013-02-08 17:05:31 +09:00
Marek Safar 6b4c3f0d72 Merge pull request #472 from MelanieT/spmanager_fix
Fix ServicePointManager.DefaultConnectionLimit to work as specified.
2013-02-07 07:05:41 -08:00
Martin Baulig db232608f4 [#7599][Web]: Use original uri to compute service point hash.
Use the original request Uri, not the proxy address, to compute
the service point hash.
2012-10-21 18:56:13 +02:00
Sebastien Pouliot 0c644b5fcc Provide a non-null X509Chain in the callback for MonoTouch (useful for custom validations) but we are not fully building it (since we do not use the output) and this can be done if customization is required 2012-10-09 19:43:52 -04:00
Melanie Thielker 9605c20c97 Fix ServicePointManager to accept the DefaultConnectionLimit property being
set as per the .NET spec.
2012-09-30 18:46:38 +02:00
Sebastien Pouliot 6fc934ea50 [OSX] Reset errors to 0 if the OS tells us that (1) the chain is ok, (2) the certificate usage is for SSL server and (3) the server identity is confirmed (2+3 were part of an earlier fix). Without this reset we depended on the mono certificate store as an extra condition (which would requires mozroots to be executed and we want to avoid this 'duplicated' requirement and trust OSX). This does not affect iOS where no mono stores exists. 2012-09-13 20:48:42 -04:00
Jonathan Pryor 1249082309 [M4A] Clear RemoteCertificateChainErrors if Android validates the chain.
The problem: Mono for Android 4.2.5 horribly broke SSL support:

	http://lists.ximian.com/pipermail/monodroid/2012-September/012213.html

Why? Because of ad89f72f (kinda): As Mono for Android doesn't provide
or use its own set of SSL root certificates (opting instead to just
let Android worry about it), the `chain.Build()` method will ALWAYS
result in SslPolicyErrors.RemoteCertificateChainErrors being returned
from GetErrorsFromChain().

The world before ad89f72f "masked" this because errors & status11 were
always cleared if Android accepted the chain; however, clearing these
out masked other bugs, such as #5706 (in which https://74.125.224.134
is accepted as valid when it can't be valid, by definition).

The fix is to clear out SslPolicyErrors.RemoteCertificateChainErrors
if Android accepts the certificate chain. Any other errors are left
unchanged, thus keeping #5706 fixed.
2012-09-13 14:46:59 -04:00
Sebastien Pouliot ad89f72f5b [M4A] Do not reset 'errors' and 'status11' when a certificate is trusted. Fix last part of #5706 2012-08-23 16:39:57 -04:00
Sebastien Pouliot 3a274aac77 [OSX|iOS] Do not reset 'errors' and 'status11' when a certificate is trusted. Use the OS to validate the certificate (as valid for SSL server usage) and for the host name checks. Fix parts of #5706 2012-08-23 16:37:23 -04:00
Jonathan Pryor 3363b136c6 Pass SSL certificate chain, not just collection, to Mono.Android.dll
Fixes BCL half of: https://bugzilla.xamarin.com/show_bug.cgi?id=6501

Today I learned that the SSL certificate collection (as held in
X509CertificateCollection) is a potentially unordered sequence of SSL
certificates, which not all versions of Android will validate.

The fix is to use the properly ordered SSL certificate chain (as held
in X509Chain), and have Android validate that.
2012-08-13 13:48:16 -04:00
Gonzalo Paniagua Javier 798784bac5 Backport from mobile 2012-07-11 18:17:36 -04:00
Marek Safar 5b82f0e08c Clean up some NET_2_0 2012-06-14 15:44:35 +01:00
Sebastien Pouliot 903ce57ce7 Propagate all errors to the (old) ICertificatePolicy or (newer) callback. Fix bug #5546 for iOS 2012-06-06 21:11:54 -04:00
Miguel de Icaza f48ceb9860 [System] Removal of the NET_2_0 in the source code
Modulo the GUID in the assembly and the GUID embedded in some
field initializers that use the assembly GUID for their name, the
assemblies are idential before and after the patch.
2012-06-02 13:16:40 -04:00
Miguel de Icaza ae0feab435 Removal of NET_1_1 defines and some NET_2_0; Both defines are true these days in Mono, no versions prior to 2.0 are supported 2012-06-01 18:04:24 -04:00
Gonzalo Paniagua Javier 9007f5e043 Avoid deadlocking when getting the ServicePoint
SSL connections were deadlocking when getting the service point for the
	connection in the last few releases of 2.10.x and in master.

	Fixes bug #4599.
2012-04-24 04:54:54 -04:00
Sebastien Pouliot e952c9a89b Do not build a managed X509Chain in MonoTouch and simply ask iOS about the chain. Other SSL related checks about the leaf certificate are still required/done. Avoid many internal exceptions since Mono's machine store does not exists inside iOS devices (note: already part of MonoTouch since 4.3) 2012-01-12 15:47:37 -05:00
Sebastien Pouliot 1db32e3410 avoid potential InvalidCastException when we already deal with bad/non-present extensions (reduce error message when -E:all is used) 2011-07-19 10:34:57 -04:00
Gonzalo Paniagua Javier 891af303aa [Socket] Implemented TCP keep alive support
Implemented SetTcpKeepAlive for ServicePoint*.
2011-01-13 18:28:16 -05:00
Gonzalo Paniagua Javier 604d5faa0b More StringComparison.Ordinal
Use StringComparison.Ordinal when calling IndexOf to find the index of
	an ASCII string.
2010-10-31 17:23:18 -04:00
Jonathan Pryor ac277b3917 Add preliminary HTTPS handling support for Android.
The problem is that Android only exposes Java APIs for ~everything of
consequence, including/especially X509 Certificate validation.  Since
we want Mono-based HTTPS support to use the underlying platform
certificates, this requires some amount of Java-using glue.  However,
we don't want to pull in a ton of Java glue into System.dll (bleh!),
so we'll instead place the glue into Mono.Android.dll's
Android.Runtime.AndroidEnvironment.TrustEvaluateSsl(), and instead
create a delegate which will invoke TrustEvaluateSsl() when needed.
2010-10-12 17:47:53 -04:00
Gonzalo Paniagua Javier 231f4decce Add env.var. to control revocation mode.
Added a new environment variable, MONO_X509_REVOCATION_MODE that lets
        the user choose the default validation mode for X509 chains.
2010-08-27 16:58:23 -04:00
Sebastien Pouliot 9c8cb87fe3 In .:
2010-07-21  Sebastien Pouliot  <[email protected]>

	* Makefile: Ensure SECURITY_DEP gets defined in our moonlight
	raw profile

In System.Net:
2010-07-21  Sebastien Pouliot  <[email protected]>

	* ServicePointManager.cs: Add special validation for Moonlight
	* WebConnection.cs: Change a define to NET_2_1

In System.Net.Security:
2010-07-21  Sebastien Pouliot  <[email protected]>

	* LocalCertificateSelectionCallback.cs:
	* SslStream.cs:
		Don't use alias in moonlight build (not needed and breaks
		compilation otherwise)


svn path=/trunk/mcs/; revision=160675
2010-07-21 13:36:35 +00:00
Sebastien Pouliot 70064ced0b In System.Net:
2010-06-29  Sebastien Pouliot  <[email protected]>

	* ServicePointManager.cs: Remove NET_2_0 defines around 
	RemoteCertificateValidationCallback

In System.Net.Security:
2010-06-29  Sebastien Pouliot  <[email protected]>

	* RemoteCertificateValidationCallback.cs: Remove SECURITY_DEP use


svn path=/trunk/mcs/; revision=159663
2010-06-29 14:13:01 +00:00
Gonzalo Paniagua Javier 610592a68d 2010-04-08 Gonzalo Paniagua Javier <[email protected]>
* ServicePointManager.cs: obtain the SubjectAltName extension the
	right way. Fixes bug #594110.


svn path=/trunk/mcs/; revision=155049
2010-04-08 14:30:27 +00:00
Gonzalo Paniagua Javier d31e514db3 2010-03-26 Gonzalo Paniagua Javier <[email protected]>
* ServicePointManager.cs: errors parsing the certificate don't prevent
	calling the callback now. Exceptions thrown parsing the certificate
	are printed to stderr in case they are library errors.


svn path=/trunk/mcs/; revision=154316
2010-03-26 20:13:23 +00:00
Gonzalo Paniagua Javier 1bc30f2f98 only check for the Mac library file once
svn path=/trunk/mcs/; revision=154237
2010-03-26 02:57:36 +00:00
Geoff Norton 519d434479 We dont do MacOSX on MacOSX
svn path=/trunk/mcs/; revision=154223
2010-03-25 22:17:02 +00:00
Sebastien Pouliot 355a27b73d In System.Timers:
2010-03-19  Sebastien Pouliot  <[email protected]>

	* Timer.cs: Removed old NET_2_0 defines and added some new
	MOONLIGHT defines (needed for the client stack)

In System.Net:
2010-03-19  Sebastien Pouliot  <[email protected]>

	* AuthenticationManager.cs: Internal type for Moonlight.
	Add BasicClient, DigestClient, NtlmClient for NET_2_1 since
	this applies to both monotouch and moonlight (client stack).
	Removed unneeded NET_2_0 defines
	* CookieContainer.cs: For Moonlight it needs to be internal in 
	System.dll and public in System.Net.dll. Removed unneeded NET_2_0
	defines
	* HttpContinueDelegate.cs: Internal type for Moonlight.
	* HttpRequestCreator.cs: Remove a MOONLIGHT define
	* HttpStatusCode.cs: For Moonlight it needs to be internal in 
	System.dll and public in System.Net.dll
	* HttpWebRequest.cs: Internal type for Moonlight. Change S.Config
	to NET_2_1 defines (applies to both monotouch and moonlight).
	Removed unneeded NET_2_0 and NET_1_1 defines
	* HttpWebResponse.cs: Internal type for Moonlight. Removed 
	unneeded NET_2_0 defines
	* IAuthenticationModule.cs: Internal type for Moonlight.
	* ICertificatePolicy.cs: Internal type for Moonlight.
	* ICredentialPolicy.cs: Internal type for Moonlight. Removed 
	unneeded NET_2_0 defines
	* IWebRequestCreate.cs: For Moonlight it needs to be internal in 
	System.dll and public in System.Net.dll
	* ServicePoint.cs: Internal type for Moonlight. Change S.Config
	to NET_2_1 defines (applies to both monotouch and moonlight)
	* ServicePointManager.cs: Remove a MOONLIGHT define
	* WebException.cs: For Moonlight it needs to be internal in 
	System.dll and public in System.Net.dll. Removed unneeded NET_2_0
	defines
	* WebHeaderCollection.cs: Internal type for Moonlight. Removed 
	unneeded NET_2_0 defines
	* WebRequest.cs: Internal type for Moonlight. Change S.Config
	to NET_2_1 defines (applies to both monotouch and moonlight)
	* WebResponse.cs: Internal type for Moonlight. Removed unneeded
	NET_2_0 defines

In System.Net.Sockets:
2010-03-19  Sebastien Pouliot  <[email protected]>

	* Socket.cs: Remove some NET_2_0 defines (using) and add a few
	MOONLIGHT defines needed to reuse Socket in the client http stack
	* Socket_2_1.cs: Remove some MOONLIGHT defines
	* SocketAsyncEventArgs.cs: For Moonlight check policy if outside
	System.dll (the client stack use sockets with it's own web 
	xdomain policy)

In System:
2010-03-19  Sebastien Pouliot  <[email protected]>

	* Uri.cs: Remove some MOONLIGHT defines

In .:
2010-03-19  Sebastien Pouliot  <[email protected]>

	* moonlight_*_System.dll.sources: Bring extra types so we can
	build a full, managed, internal HTTP stack to be reused for SL3+
	* Makefile: Add a INSIDE_SYSTEM define when compiling System.dll
	to makes it possible to rebuild the same types in System.Net.dll


svn path=/trunk/mcs/; revision=153916
2010-03-19 19:01:31 +00:00
Gonzalo Paniagua Javier ae669ce233 remove commented out code
svn path=/trunk/mcs/; revision=153446
2010-03-11 06:07:57 +00:00
Gonzalo Paniagua Javier e7528a2e37 Moved chain building and validation from Mono.Security to System
to better support the 2.0 validation callback.


svn path=/trunk/mcs/; revision=153443
2010-03-11 06:02:08 +00:00
Gonzalo Paniagua Javier 5c20ab97e6 2010-03-01 Gonzalo Paniagua Javier <[email protected]>
* System.Net/WebConnection.cs: attach a validation callback to the new
	event in Mono.Security.
	* System.Net/ServicePointManager.cs: added a new ValidationHelper
	class that takes care of building the certificate chain and perform
	all the check that were done in Mono.Security before. This way the 2.0
	server certificate validation callback can get all the data it needs.
	* System.Net.Security/SslStream.cs: don't do anything if a chain
	element has no error.

	Fixes bug #584050.

svn path=/trunk/mcs/; revision=152654
2010-03-01 09:01:14 +00:00
Jb Evain 288e614ea4 bring Mono Security to monotouch
svn path=/trunk/mcs/; revision=141615
2009-09-09 15:34:58 +00:00
Jb Evain f2a6f61bad use a 2.0 network stack for MONOTOUCH
svn path=/trunk/mcs/; revision=139255
2009-08-02 15:43:12 +00:00
Gonzalo Paniagua Javier f760e84e58 2009-07-02 Gonzalo Paniagua Javier <[email protected]>
* ServicePointManager.cs: implement ServerCertificateValidationCallback.
	* DefaultCertificatePolicy.cs: if there's a SCVC registered, don't do
	normal error checking.a


svn path=/trunk/mcs/; revision=137253
2009-07-02 07:39:40 +00:00
Gonzalo Paniagua Javier 2cc04012e9 2008-10-27 Gonzalo Paniagua Javier <[email protected]>
* ServicePointManager.cs: set the default limit of connections from
	the configuration file(s) on startup.
	Bug #339422 fixed.


svn path=/trunk/mcs/; revision=117126
2008-10-27 04:58:02 +00:00