ManagedHandler_HttpClientHandler_ConnectionPooling_Test didn't assert
IDisposable (though did have a Dispose method), so it didn't clear the
environment variable that says to use the prototype managed handler in tests.
This means that any tests which should still be using the curl provider end up
using the managed provider until another managed test runs.
So now it's disposable, and a failure we were expecting, but not seeing, on
macOS 10.13 is asserting itself again.
Commit migrated from https://github.com/dotnet/corefx/commit/3dac2dbf20a56e6b525e078e977bfeed3ae8de8a
* Reconcile behavior of MaxRequestContentBufferSize across .NET Core
The HttpClientHandler property, MaxRequestContentBufferSize, has been
deprecated. This PR reconciles the behavior of the getter and setter of
the property.
Similar to other decisions in HttpClient PRs with these kinds of
behavior differences, we are not going to throw PNSE. We will document
the differences in the AppCompat docs.
Fixesdotnet/corefx#7879
* Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/e740973fed660da4426218bf2ec4be35a60ad095
* Re-enable anf fix Http tests for UAP
* Removed ActiveIssue from a bunch of Http tests.
* Converted some ActiveIssue to SkipOnTargetFramework due to
platform differences.
* Change some tests to use RemoteInvoke to get process isolation
since UAP will cache connections per-process.
* Removed a duplicate ChannelBinding test. There is already the
same test in HttpClientHandlerTest.ServerCertificates.cs
(PostAsync_Post_ChannelBinding_ConfiguredCorrectly). And that
test checks more things.
Contributes to dotnet/corefx#20010
* Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/a3cd07a7b608358710ac073cbe41f65866aa929a
* Fix HttpClientHandler UAP to use a filtered set of client certs
My earlier PR dotnet/corefx#22022 refactored the GetEligibleClientCertificates code
into a Common method. However, I neglected to actually use it in the UAP
HttpClientHandler!
Fixed the handler to properly filter down the set of client
certificates.
Added new tests to verify functionality. While doing this, I discovered
that the tests need to run in an isolated process due to the per-process
caching behavior of the UAP HTTP stack.
So, I used the RemoteInvoke method. I had to duplicate some of the new
tests using Fact instead of using Theory. This is because the
RemoteInvoke doesn't allow non-string parameters and I had to pass
in X509Certificate2 objects. So, I separated out each variant into its
own Fact test.
* Address PR feedback
* Fix code refactoring to properly filter client certificates.
* Fix test names in nameof() blocks.
* Disable a test from using the managed handler.
* Address PR feedback
* Remove unneeded using statements.
* Disable managed handler in some SslProtocols tests.
Commit migrated from https://github.com/dotnet/corefx/commit/9c4af2973699aea35ce5c60c00f7dd14398e7a14
* Implement client certificates for HttpClient on UAP
Added code for HttpClientHandler.ClientCertificates on UAP.
Moved code duplicated in several places into a common helper class, CertificateHelper.
Then I discovered a bug introduced into GetEligibleCertificates (from PR dotnet/corefx#21908) that
doesn't properly filter by EKU or KeyUsage if there is only one cert (this was failing
the WinHttpHandler Unit tests). So, I removed that optimization.
Used the new Azure test endpoint for client certificates. I did not use the loopback
server because there is a problem using it with HttpClient in UAP. There is a crash
in the SslStream.AuthenticateAsServer that I was not able to diagnose yet. It will
require a lot of time debugging and I wanted to get this HttpClientHandler feature
done now. Tracking that investigation with dotnet/corefx#22021.
Fixesdotnet/corefx#21628
Contributes to dotnet/corefx#14542
* Address PR feedback
* Moved method to Windows-only Common file
* Fixed some line spacing
Other potential refactoring/optimizations will be looked into in dotnet/corefx#22045
Commit migrated from https://github.com/dotnet/corefx/commit/472b8d8ec212c2afb107dea305b4624c4989a79f
* Fix HttpClientHandler ServerCertificateCustomValidationCallback for UWP
This PR implements the ServerCertificateCustomValidationCallback for UWP. While implementing this, I discovered that the behavior of
the current .NET Core code is incorrect regarding how to propagate exceptions from the user provided callback. I opened up a new
issue dotnet/corefx#21904 and revised the test as well.
Fixesdotnet/corefx#21627
* Address more PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/e30fdc38e60f6fa2ed8e7e103d1f8c44655438cd
One test needed to be fixed to deal with the fact that currently the ManagedHandler doesn't throttle connections and can end up getting denied connection errors from the server when exceeding the listen backlog size employed.
Commit migrated from https://github.com/dotnet/corefx/commit/47ffa8b49cf3d04be888f4d1e1dc287cdcbbe5e5
The tests that verify PNSEs getting thrown were failing incorrectly when the managed handler was used on platforms like CentOS where our CI system has an old libcurl installed. For now, I've worked around it in a very manual fashion, but longer term we need a better way of using the same tests against multiple handlers substituted dynamically.
Commit migrated from https://github.com/dotnet/corefx/commit/fb2f2e8be64d6bf2c26030ef63d1e5cb004e8a64
The condition for these tests needs to be adjusted. The tests in question are verifying that a PNSE is thrown on platforms that don't have an OpenSSL backend, but that's irrelevant when using the managed handler, on which these tests actually successfully make connections rather than throwing.
Committing directly to unblock CI.
Commit migrated from https://github.com/dotnet/corefx/commit/4f9322825a9da4f47677b1413f0feabed3fd746b
One of the Windows-only tests is expecting SslStream's ChannelBinding's ToString() to output the data from the binding in a specific format, matching what WinHttp's outputs. This makes that happen. And enables more tests.
Commit migrated from https://github.com/dotnet/corefx/commit/0cd7eeabb6b91c44827592bd45f8312dcb961388
This PR clarifies how credential handling and specifically default
logged-on credentials actually works on the UAP platform.
First, "default credentials" are the current credentials of the
logged-on user, typically on an enterprise network joined to an
Active Directory domain. When these credentials are sent to a
proxy or server, only Negotiate, Kerberos, or NTLM schemes are
used. Those credentials can never be sent via other schemes
like basic or digest.
.NET Framework traditionally has two ways for developers to specify
using default logged-on credentials to send to the server. Either
set the .UseDefaultCredentials property to true or specify
CredentialCache.DefaultCredentials to the .Credentials property.
For proxy credentials, the developer could pass DefaultCredentials
via the custom IProxy object or via the .DefaultProxyCredentials
property.
.NET Framework would send default credentials anywhere (intranet
or internet) if specified by the developer.
The UAP platform implementation of System.Net.Http uses a different
set of rules for sending default credentials. It is based on whether
the app has Enterprise Authentication capability as well as if the
endpoint is specified in an intranet zone. This design is part of
the base native WinInet and WinHTTP stacks. It was a design choice
to provide optimum security as well as convenience for developers
writing apps for enterprise scenarios.
This PR does a few things. First, it keeps the .NET ICredentials
properties stored separately so that they correctly round-trip
on get and set. .NET NetworkCredential has 3 parameters (domain,
user, password). But WinRT PasswordCredential only has 2 parameters
(user, password). We now convert to the WinRT objects only when
we need to use them.
Second, this PR clarifies that the .UseDefaultCredentials property
is basically a no-op because the API models of default credentials
handling is different on the UAP platform as described above.
These platform differences will be documented here:
https://github.com/dotnet/corefx/wiki/ApiCompatFixesdotnet/corefx#19642Fixesdotnet/corefx#21510
Commit migrated from https://github.com/dotnet/corefx/commit/2c33453f3e4064c75d404c6f3590ddf00a377d10
Due to platform differences on UAP and the current use of WinRT APIs to
implement that HTTP stack, a few properties won't have the same defaults
or behavior.
CheckCertificateRevocationList default value is true for UAP and can't
be changed. However, on UAP, revocation checking that results in an
indeterminate status (i.e. revocation server offline) is treated the
same as a valid result. This is the behavior of the underlying WinRT
APIs.
SslProtocols default value is SslProtocols.None which is the same as the
rest of .NET Core. 'None' means to use the system default. However, changes
to this property value will be ignored.
Similar to the decision made in PR dotnet/corefx#21403, we don't throw PNSE for these
differences. Instead we just no-op on the property setter.
The behavior differences will be documented in:
https://github.com/dotnet/corefx/wiki/ApiCompat
Contributes to dotnet/corefx#18116.
Commit migrated from https://github.com/dotnet/corefx/commit/711f785f072c8131b9d49792eeab02d2d55be662
The HttpClientHandler for UAP does not properly implement the PreAuthenticate
property. This is because on UAP, HttpClientHandler is built on the WinRT
APIs which in turn are built on WinInet. And WinInet always uses authentication
caching internally and this results in the net effect of PreAuthenticate always
being "true".
The default for .NET Framework and .NET Core (non-UAP) is "false".
When this property was first added to .NET Core 1.1, the UAP version defaulted
to true and the setter would throw PNSE.
As part of .NET Core 2.0, API surface for networking APIs was expanded. This
resulted in HttpWebRequest exposing and implementing a "PreAuthenticate" property,
which is what it has historically done in .NET Framework. On .NET Core, HttpWebRequest
is built on top of HttpClient. And so, HttpWebRequest was enhanced in .NET Core 2.0
to set the default of PreAuthenticate to false. But this later caused the PNSE
exception to surface and this exception was caught in UWP app-compat testing.
Essentially, we had now created the default HttpWebRequest to always throw an
exception.
So, in PR dotnet/corefx#18105, the PNSE in HttpClientHandler.PreAuthenticate was commented out
and thus the setter became a no-op.
This PR basically acknowledges this situation and removes the TODO from this change.
Since there is no good way to implement the actual HttpClientHandler.PreAuthenticate
property, I left the getter default to return "true" which is closer to reality of
what happens on UAP (even though this default value is different from .NET Framework
or the rest of .NET Core). And, in terms of the setter for the property, I opted to
leave it as a no-op. This seems like the best compromise outcome for now and will
generate less distraction for developers rather than throwing an exception all the
time.
The rest of this PR moves the ActiveIssue's from the class level to the method level
as part of eventually solving all of them. In addition, I added a new test case to
validate the HttpClientHandler constructor defaults that are different on the UAP
platform.
Fixesdotnet/corefx#18104
Commit migrated from https://github.com/dotnet/corefx/commit/c3b2f15d90972a5607415582681584965f16c01d
After my PR dotnet/corefx#21325, I discovered an edge case where we need to check for
a non-null Proxy property in the underlying WebRequest.
On .NET Framework, System.Net.Http is built on WebRequest
(HttpWebRequest) and is subject to side-affects from it. The static
property WebRequest.DefaultWebProxy affects the initial value of
WebRequest.Proxy. So, it's possible that a developer may have set
WebRequest.DefaultWebProxy to null prior to using System.Net.Http in the
app.
The net affect of this is that that won't be any proxy used as the
system default proxy and thus the
HttpClientHandler.DefaultProxyCredentials is ignored.
On .NET Core, there is no relationship between System.Net.Http and
System.Net.WebRequest. So, in all cases on .NET Core, where a developer
has specified HttpClientHander.UseProxy=true and HttpClientHandler.Proxy
= null (default values), the handler will always try to use the system
default proxy (if configured).
Commit migrated from https://github.com/dotnet/corefx/commit/eac755df47f70e5ef3853c0b71ed4ab12455bb96
- Add a ManagedHandler field to both the Windows and Unix HttpClientHandler builds, and change the members to switch based on which is being used. The default is still to use WinHttpHandler and CurlHandler respectively, but setting an environment variable prior to constructing an HttpClientHandler will switch it to use ManagedHandler.
- Add test classes that will run the tests again but with the managed handler. Some of the test classes are commented out due to current failures.
- Fixed a few tests.
Commit migrated from https://github.com/dotnet/corefx/commit/b238d0d760a2588513c443f3a4c991222fd037bb
This bug was discovered in internal testing when this code was being
ported to .NET Framework vNext. Due to all these tests being previously
disabled on NETFX, the bug was missed.
The HttpClientHandler.DefaultProxyCredentials property is only used when
an explicit proxy is not specified (HttpClientHandler.Proxy==null) but a
proxy is still desired (HttpClientHandler.UseProxy==true). In this case,
the semantics implied are to use the system default proxy settings to
find a proxy. In that case, the credentials specified by
DefaultProxyCredentials should be passed to the webrequest.Proxy object
which, by default, points to the system proxy.
Commit migrated from https://github.com/dotnet/corefx/commit/e5306b55c0267c0369e5da9bef0467d2ea4e9b51
This change to enable remote execution of all corefx tests in UAP. Because the remote execution code for UAP is using WinRT APIs and to avoid forcing adding UAP configuration to all test projects, we factor the remote execution code into its own test library (called TestHelper) which is cross compiled.
Commit migrated from https://github.com/dotnet/corefx/commit/eb2f543b189e8f7f9ae4c31e832ac9d3c22bb41a