Commit Graph
39 Commits
Author SHA1 Message Date
Viktor 7e4b5f9b01 Update src folder
Commit migrated from https://github.com/dotnet/corefx/commit/817c36a05ef2d92e59ce6f5a37e2be50076361b3
2019-04-02 19:21:57 +02:00
David Shulman 327b35cd6d Fix HttpClient EKU tests (dotnet/corefx#35240)
A set of HttpClient tests related to ClientCertificates were always failing on my machine:

System.Net.Http.Functional.Tests.SocketsHttpHandler_HttpClientHandler_ClientCertificates_Test
* method="Manual_SendClientCertificateWithClientAuthEKUToRemoteServer_OK"
* method="Manual_SendClientCertificateWithNoEKUToRemoteServer_OK"
* method="Manual_SendClientCertificateWithServerAuthEKUToRemoteServer_Forbidden"

These tests would generate an exception:
>System.Net.Http.HttpRequestException: An error occurred while sending the request. --->
 System.IO.IOException: The remote party requested renegotiation when AllowRenegotiation was set to false.

Similar to the tests failing and fixed in PR dotnet/corefx#35225, the CI machines don't have the test
root certificate installed. So, the tests weren't running in CI and the failures weren't noticed.

The root cause of the test failures is due to using SocketsHttpHandler. It is always setting
`SslStream.AllowRenegotiation` to false when first attempting to connect via HTTP/2. This is fine
if the connection is truely HTTP/2 since HTTP/2 doesn't support TLS renegotiation. However, if the
remote endpoint doesn't support HTTP/2 and thus connects with HTTP/1.1, then the SslStream should
not have AllowRenegotiation set to false. Client certificate scenarios frequently have the server
ask for the client certificate later in the connection process. So, TLS renegotiation is used. Opened
new issue dotnet/corefx#35239 to fix this in SocketsHttpHandler (or SslStream).

As part of fixing these tests, I refactored them into a single Theory test. But I had to workaround
complications due to using RemoteInvoke. I added a new RemoteInvoke overload to handling passing
an additional parameter.

Commit migrated from https://github.com/dotnet/corefx/commit/0c2ccd172157e0ebf1957e1bbcd5f07786ad6e3d
2019-02-11 17:27:04 -08:00
Geoff Kizer d33615e499 rename HttpClientTestBase to HttpClientHandlerTestBase
Commit migrated from https://github.com/dotnet/corefx/commit/b26e2a66e5c41c3263caf5fdaa8a1811dd360e33
2019-01-09 02:44:04 -08:00
Tomas Weinfurt 6b900e8e6f socket handler does not depend on platfrom curl (dotnet/corefx#32543)
Commit migrated from https://github.com/dotnet/corefx/commit/20b2f55558f729f24fc063f520b35ab0adeec924
2018-09-29 14:28:39 -07:00
Jeremy Barton e54864fbc0 Check for the specific in-use version of OpenSSL when working with libcurl
Rather than check a generic 1.0/1.1, test for the specific library version that
the crypto shim has loaded.  This makes things work when both libcurl
and the crypto shim are using OpenSSL 1.1 and also prevents a state where two
different copies of the library (at different patch versions) are utilized.

Commit migrated from https://github.com/dotnet/corefx/commit/d33f8435461028ec131fcfd42232098aaf3e6ded
2018-09-26 15:35:35 -07:00
David Shulman ef3c76c2d1 Investigate / skip failing UAP Http tests (dotnet/corefx#30064)
Worked thru most of the tests previously disabled. Opened new issues for a bunch of them
with detailed analysis. Some tests are being permanently skipped due to differences in UAP
platform.

Contributes to dotnet/corefx#29802

Commit migrated from https://github.com/dotnet/corefx/commit/4e91b8620498cc82faafecb619bca630e277d6d3
2018-06-02 09:30:22 -07:00
David Shulman e7ae16d343 Disable Http tests on UAP (dotnet/corefx#29803)
Many dozen of Http tests are failing on UAP test runs. This is not showing up during PR/CI
because the UWP leg only is building the product and test sources and not actually running
any tests. However, the test failures show up in Helix and also when run locally on a dev machine.

So, for now, I'm disabling some of these tests so that the inner and outer test runs will pass.

Contributes to dotnet/corefx#29802
Closes dotnet/corefx#27953

Commit migrated from https://github.com/dotnet/corefx/commit/3326f3f24dd083f0966c8f71c7d1e8c2caa1ddae
2018-05-20 09:33:35 -04:00
David Shulman a6af7cfd24 Fix client certificate lifetime handling in tests (dotnet/corefx#29758)
* Fix client certificate lifetime handling in tests

This was a difficult bug to track down. Our use of importing PFX files into the
tests has problems due to a combination of issues. The summary is that these
issues cause the private key (which is written to a temp file on disk) to get
corrupted/deleted. This is why we would get random errors about "invalid client
credentials" when using client certificates in HttpClient (or SslStream).

Thanks to @bartonjs for helping me work thru this.

The lifetime of the temp file containing the private key is associated with the managed
X509Certificate2 object that is created. However, our use of X509Certificate2Collection
followed by the use of the .Find() API in
[GetEligibleClientCertificate](https://github.com/dotnet/corefx/blob/dotnet/corefx@10aa8277de2521fb1e6a5b42d053ad8cc947be81/src/Common/src/System/Net/Security/CertificateHelper.cs#L55-L59)
causes new managed objects to get created including both a new collection object and
new certificate objects wrapping the existing native PCCERT_CONTEXT of the old managed
certificate object. This causes lifetime issues for the temp file containing the private
key since the old managed objects are GC'd.

In terms of fixing this for the tests, I've optimized the Configuration.Certificates
helper and removed constructs that we don't actually use in our tests. Switching from
using .Import() on the collection object to actually creating the X509Certificate2
object directly helps with managing the lifetime of the certificate.

I will be doing a follow-up PR to optimze GetEligibleClientCertificate() to switch from
using .Find() and instead directly query the certificates in the original collection.
This will result in less managed objects being created as well as avoid additional private
key lifetime issues for certificates imported that use the default X509KeyStorage.DefaultKeySet
flags.

I also fixed a problem with the test which was always failing on NETFX.

Closes dotnet/corefx#9543

* Remove Mutex


Commit migrated from https://github.com/dotnet/corefx/commit/75ba6cd878b6764e1f400c839271866f7d2a049a
2018-05-17 10:46:18 -07:00
Caesar Chen b2d22149da miscellaneous fix (dotnet/corefx#29492)
Commit migrated from https://github.com/dotnet/corefx/commit/38ad17100349ef286edeb67ddffe4c44ba4e51e1
2018-05-03 14:31:45 -07:00
Stephen Toub d5ba24bff1 Several Http test fixes to hopefully improve test reliability (dotnet/corefx#29238)
- Add “Connection: close\r\n” response header in more cases where the loopback server explicitly closes a connection, and in particular where the client makes multiple connections.
- Change several Task.WaitAlls on paired tasks to instead use our WhenAllOrAnyFailed helper.

Commit migrated from https://github.com/dotnet/corefx/commit/cebcf436358600a4808656b142a74f57d1e8f6f0
2018-04-20 18:21:18 -04:00
Caesar Chen 9df60dc56a Make SocketsHttpHandler default Handler (dotnet/corefx#27821)
* set SocketsHttpHandler to default

* address feedback

* fix if check for 28002


Commit migrated from https://github.com/dotnet/corefx/commit/2b850f6fe5fd3171c2554da965cb07070e1d648e
2018-03-14 00:34:56 -04:00
David Shulman a8c1ba9b4f Fix SocketsNetHttpHandler TLS client cert handling (dotnet/corefx#27753)
SocketNetHttpHandler was not filtering down the client certificates when sending in
"Manual" mode. This caused a client certificate to be sent to a server when it
didn't have the proper EKU OID for "Client Authentication".

Changed this so that both "Manual" and "Automatic" modes will use the CertificateHelper
GetEligibleCertificate() API.

Fixes dotnet/corefx#23128

Commit migrated from https://github.com/dotnet/corefx/commit/d0cb45113979a22b216d630dbe9200d19b401691
2018-03-06 07:43:44 -08:00
Stephen Toub b6b2da9344 Improve test coverage of SocketsHttpHandler (dotnet/corefx#27135)
* Improve test coverage of SocketsHttpHandler

Used code coverage information to write targeted tests to cover various uncovered paths in SocketsHttpHandler.  Along the way fixed a variety of issues relating to throwing the wrong exception type, a stack overflow due to an unexpected recursive call, etc.

* Address PR feedback

* Re-disable a test


Commit migrated from https://github.com/dotnet/corefx/commit/39677219aaeab8c6591b625ab2874acb17eaf4ef
2018-02-16 12:02:45 -05:00
Geoff Kizer bf6635fcfd add response generation overloads
Commit migrated from https://github.com/dotnet/corefx/commit/6943fc7c0e92359e6335a618f6ff5ee8402af4ac
2018-02-13 16:04:26 -08:00
Geoff Kizer b94eefba0f reorganize and cleanup some LoopbackServer code
Commit migrated from https://github.com/dotnet/corefx/commit/ec6a7215bb28a061d2357d8c3874447bc575132d
2018-02-13 15:43:59 -08:00
Stephen Toub 89dfde815e Expose SocketsHttpHandler
- Renames ManagedHandler to SocketsHttpHandler
- Moves a bunch of files around accordingly
- Updates System.Net.WebSockets.Client to use SocketsHttpHandler directly
- Updates System.Net.Http's tests with a reflection-based rather than TLS-based method for instantiating an HttpClientHandler backed by a SocketsHttpHandler.


Commit migrated from https://github.com/dotnet/corefx/commit/852d40e723c849e8d0c486676d40332343e12ca5
2018-02-08 19:12:50 -05:00
Stephen Toub 7be9b5bb5f Switch tests to use thread-local switch for ManagedHandler
And as a result re-enable parallelism of the test suite, which on my machine reduces the running time of the outerloop tests from 150s to 45s.


Commit migrated from https://github.com/dotnet/corefx/commit/3db504ec31fb03162b33e0658870aef5af4e4abe
2017-09-21 08:26:44 -04:00
Stephen Toub 50805a924a Update TODOs with issue numbers
Commit migrated from https://github.com/dotnet/corefx/commit/924d34b8a04eb1bc0f005848d784d7d414d0d4d3
2017-08-11 15:34:57 -04:00
David Shulman 113a821137 Fix HttpClientHandler UAP to use a filtered set of client certs (dotnet/corefx#22075)
* 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
2017-07-11 16:39:00 -07:00
David Shulman 823f81b56e Implement client certificates for HttpClient on UAP (dotnet/corefx#22022)
* 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.

Fixes dotnet/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
2017-07-10 16:52:07 -07:00
Stephen Toub fd63714f4a Re-enable ManagedHandler_HttpClientHandler_ClientCertificates_Test and ManagedHandler_HttpClientHandler_ServerCertificates_Test
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
2017-07-05 12:43:12 -04:00
Santiago Fernandez Madero c65dd7a4bd Test attributes cleanup for Uap now that Uap flag includes UapAot (dotnet/corefx#20108)
* Update xunit extensions to unify TargetFrameworkMonikers.Uap to include UapAot

Commit migrated from https://github.com/dotnet/corefx/commit/652d12bf31606eeef8fe8b9a7bf1cc7af06f6352
2017-05-22 15:10:24 -07:00
David Shulman d899bda510 Disable System.Net.Http tests on UAP/UAPAOT (dotnet/corefx#20017)
Disable a bunch of System.Net.Http tests on UAP/UAPAOT platform.

Both inner and outer loop tests now run clean for System.Net.Http

Commit migrated from https://github.com/dotnet/corefx/commit/38cd7f91dbbc5ac4001bf15762a8e244f5ec3a70
2017-05-19 14:28:54 -07:00
Daniel Harvey 252cdc5e95 Bulk updates of tests for AssertExtensions (dotnet/corefx#18491)
Bulk update to AssertExtensions.Throws for AOT support. This doesn't disable Assert.Throws.

Commit migrated from https://github.com/dotnet/corefx/commit/b43b4df2e0e2182154bb0f425cb4a61bc1269828
2017-04-18 09:52:02 -07:00
Caesar Chen b6892a28ed change the test label and add string to the resource file of WinHttpHandler to correct build error
Commit migrated from https://github.com/dotnet/corefx/commit/f57d3f2b4ee02c1e7cdc0a7d649eeda7d7a680d4
2017-03-16 14:48:58 -07:00
Caesar Chen eb24955a77 fix the HttpClientHandler.ClientCertificates behaviour when ClientCertificateOption.Automatic is set
Commit migrated from https://github.com/dotnet/corefx/commit/72322773ec42b011622e8162acfdff4ecc3beb0c
2017-03-16 13:21:12 -07:00
Jeremy Barton b978bc6f2c Merge remote-tracking branch 'dotnet/master' into master_to_applecrypto
Conflicts:
	netci.groovy
	src/System.Net.Security/src/System/Net/Security/SecureChannel.cs
	src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/OpenSslX509Encoder.cs
	src/System.Security.Cryptography.X509Certificates/src/Resources/Strings.resx
	src/System.Security.Cryptography.X509Certificates/tests/Cert.cs
	src/System.Security.Cryptography.X509Certificates/tests/CollectionImportTests.cs
	src/System.Security.Cryptography.X509Certificates/tests/CollectionTests.cs
	src/System.Security.Cryptography.X509Certificates/tests/PfxTests.cs
	src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs


Commit migrated from https://github.com/dotnet/corefx/commit/5d7aec3e00afd35d0211b50c0630a1614a548726
2017-03-10 17:44:40 -08:00
Jeremy Barton 74fbe34b84 Initial implementation of X509Certificates, HttpClient, and SslStream for macOS (dotnet/corefx#16445)
Broken by this change:
* A lot of TLS CipherSuites have no metadata defined.
* macOS does not support version skipping in TLS.  So `Tls | Tls12` is an invalid choice.

In this change:
General:
* All OSStatus related exceptions now look up the error message.

X509Certificates:
* X509Certificate moves to using SecCertificateRef from OpenSSL's X509.
* X509 metadata comes from a managed reader after being loaded by Security.framework,
due to the significant amount of data that has no public export in Apple's libraries.
* Significant code was factored out to be shared by OpenSSL and Apple implementations for X500DistinguishedName and X509Certficate2Collection.Find.
* Loading a PFX (or, rather, the private keys from a PFX) via Apple's platform
requires importing into a Keychain, and a Keychain requires a file on disk.
A temporary keychain is created during cert loading and erased when safe.
Like the perphemeral key load on Windows this can leak files due to
abnormal program termination.
* The X.509 My store for CurrentUser and LocalMachine are the default (user) and System keychains.
* The X.509 Root store is an interpretation of the Apple SecTrustSettings data.
* The X.509 Disallowed store hasn't been implemented yet, but should be a very small change.
* Other X.509 stores cannot be created due to keychain complexity.

HttpClient:
* Initialization no longer wakes up OpenSSL

SslStream:
* New implementation based on Apple SecureTransport.
* Currently has support for SNI (for AuthenticateAsClient)


Commit migrated from https://github.com/dotnet/corefx/commit/3b19899963606a34e1623e0926b90fe907197ee6
2017-03-01 14:45:41 -08:00
Steve Harter 4fc05a19f5 Improve CI: change Http test ActiveIssue(Windows) to (Any) (dotnet/corefx#16368)
Commit migrated from https://github.com/dotnet/corefx/commit/8bf03424d20922170572803fa3f3c17671e4d197
2017-02-21 18:24:25 -06:00
Steve Harter be18ea33cc Disable network test that is failing regularly (dotnet/corefx#16167)
Commit migrated from https://github.com/dotnet/corefx/commit/7df0cd05c67c28f869a997dfc4423813c2bd9f2a
2017-02-14 16:58:24 -08:00
Lakshmi Priya Sekar 6bff1b3000 Fix networking test activeissues in System.Net.Http
Commit migrated from https://github.com/dotnet/corefx/commit/dd65f89ef9806067779eb63b884d9317dad68202
2017-02-03 12:31:59 -08:00
Eric St. John f6f23740a5 Update Http tests to target ns1.7 + ns1.3
I had to add a namespace alias due to System.Configuration now being
defined by System.Runtime.


Commit migrated from https://github.com/dotnet/corefx/commit/6e86da5cc3efb88db6b932f01c9a4f9e66e84f8c
2016-10-20 14:31:18 -07:00
Justin Van Patten aa68f5ce2f Replace uses of Xunit.PlatformID with renamed TestPlatforms
Replace uses of `Xunit.PlatformID` with renamed `TestPlatforms` because
the old name conflicts with `System.PlatformID` and should be plural
according to the design guidelines for flags enums.


Commit migrated from https://github.com/dotnet/corefx/commit/5179dda7331b1e201519adf76ce9ae69ffe2a0f6
2016-10-01 17:18:41 -07:00
David Shulman 935520c1dc Disable most networking tests for default CI runs
Lately, the CI system and test server infrastructure has been overloaded with many PRs. This is causing many networking tests to randomly fail due to resource exhaustion caused by so many simultaneous PR runs on the same CI machines. This occurrs not only when using an external test server endpoint (corefx-net.cloudapp.net) but also loopback servers.

To improve engineering efficiency for the team, we are moving most of the tests in the networking libraries from the default CI runs (innerloop). For developers working on networking libraries, the networking tests can be run by invoking the "outerloop" tests.

We will not be allowing any merges of PRs in the networking libraries unless the outerloop tests are also run by the developer.

This affects tests in the following libraries right now:

* System.Net.Http
* System.Net.Http.WinHttpHandler
* System.Net.Sockets
* System.Net.Security
* System.Net.WebSockets.Client

I will be working on fine tuning these exclusions (issue dotnet/corefx#11345) to try to bring back tests into the innerloop runs when we have begun to address the infrastructure issues.


Commit migrated from https://github.com/dotnet/corefx/commit/defbb8afd11b317f6b5cc2f4422a03d701b6dba3
2016-09-01 11:23:40 -07:00
David Shulman 9449dda9a7 Enhance LoopbackServer to return received data
Modified the test LoopbackServer so that it can return the received data in the helper methods. This allows more use of the
simple ReadRequestAndSendResponseAsync() method instead of having to use the more complex methods.

Modified a few HttpClient tests to take advantage of this. More tests will be simplified in future PRs.


Commit migrated from https://github.com/dotnet/corefx/commit/14c8ddd89be1fac31a472efdcaee184ba9d62e58
2016-08-26 12:11:43 -07:00
Cristian Pop 7a3d76b180 Adding multi-machine scripts and unifying configuration.
Commit migrated from https://github.com/dotnet/corefx/commit/c354b2d44f6988a20a9f7be4a1b996ef7fbc873a
2016-06-28 12:38:07 -07:00
Stephen Toub def7b43d50 Mark another ActiveIssue
Commit migrated from https://github.com/dotnet/corefx/commit/daa30fcf33d57203456ed6c0ce8c42650074d5db
2016-06-20 14:48:11 -04:00
Stephen Toub 5a23884046 Tweak HTTP client certificates test and add ActiveIssue
With forced GC/finalization at the right moment, the test currently fails on Windows.


Commit migrated from https://github.com/dotnet/corefx/commit/4cdb8dc1ba73ef02ef719b9a0ee336dbefca3b10
2016-06-20 08:37:30 -04:00
Stephen Toub ea6cd05418 Add some HttpClientHandler client certificate tests
And fix a small bug discovered from this, lack of argument validation when setting the enum value.


Commit migrated from https://github.com/dotnet/corefx/commit/483aa5a3012fe78ea001ece1b0404b18c0b90a29
2016-06-03 13:09:23 -04:00