Files
dotnet-runtime/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.ServerCertificates.Unix.cs
T
2017-05-02 06:49:19 -04:00

71 lines
2.5 KiB
C#

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Net.Security;
using System.Net.Test.Common;
using System.Runtime.InteropServices;
using System.Security.Authentication.ExtendedProtection;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using Xunit;
namespace System.Net.Http.Functional.Tests
{
public partial class HttpClientHandler_ServerCertificates_Test
{
private static bool ShouldSuppressRevocationException
{
get
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return false;
}
// If a run on a clean macOS ever fails we need to consider that "false"
// for CheckCertificateRevocationList is actually "use a system default" now,
// and may require changing how this option is exposed. Considering the variety of
// systems this should probably be complex like
// enum RevocationCheckingOption {
// // Use it if able
// BestPlatformSecurity = 0,
// // Don't use it, if that's an option.
// BestPlatformPerformance,
// // Required
// MustCheck,
// // Prohibited
// MustNotCheck,
// }
if (CurlSslVersionDescription() == "SecureTransport")
{
return true;
}
return false;
}
}
internal static bool BackendSupportsCustomCertificateHandling
{
get
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return false;
}
// For other Unix-based systems it's true if (and only if) the openssl backend
// is used with libcurl.
return (CurlSslVersionDescription()?.StartsWith("OpenSSL") ?? false);
}
}
private static bool BackendDoesNotSupportCustomCertificateHandling => !BackendSupportsCustomCertificateHandling;
[DllImport("System.Net.Http.Native", EntryPoint = "HttpNative_GetSslVersionDescription")]
private static extern string CurlSslVersionDescription();
}
}