You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.309
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
parent
ee1447783b
commit
94b2861243
@@ -839,17 +839,11 @@ namespace System.ServiceModel.Channels
|
||||
{
|
||||
AspNetEnvironment env = AspNetEnvironment.Current;
|
||||
|
||||
// When IIS hosted, WebSockets can be used if the pipeline mode is integrated and the WebSocketModule is loaded.
|
||||
// Otherwise, the client requests will not be upgraded to web sockets (see the code in HostedHttpTransportManager.HttpContextReceived(..)).
|
||||
// We do the checks below (and fail the service activation), to avoid starting a WebSockets listener that won't get called.
|
||||
// When IIS hosted, WebSockets can be used if the pipeline mode is integrated
|
||||
if (!env.UsingIntegratedPipeline)
|
||||
{
|
||||
throw FxTrace.Exception.AsError(new NotSupportedException(SR.GetString(SR.WebSocketsNotSupportedInClassicPipeline)));
|
||||
}
|
||||
else if (!env.IsWebSocketModuleLoaded)
|
||||
{
|
||||
throw FxTrace.Exception.AsError(new NotSupportedException(SR.GetString(SR.WebSocketModuleNotLoaded)));
|
||||
}
|
||||
}
|
||||
else if (!WebSocketHelper.OSSupportsWebSockets())
|
||||
{
|
||||
|
@@ -1 +1 @@
|
||||
f50e3667174e51a9ed111f895086c89240f0296c
|
||||
ee3fbc127a7fcb92e6aa44345193357a75edc7ee
|
@@ -202,8 +202,8 @@ namespace System.ServiceModel.Channels
|
||||
internal const bool RequireClientCertificate = false;
|
||||
internal const int MaxFaultSize = MaxBufferSize;
|
||||
internal const int MaxSecurityFaultSize = 16384;
|
||||
internal const SslProtocols SslProtocols = System.Security.Authentication.SslProtocols.Ssl3 |
|
||||
System.Security.Authentication.SslProtocols.Tls |
|
||||
|
||||
internal const SslProtocols SslProtocols = System.Security.Authentication.SslProtocols.Tls |
|
||||
System.Security.Authentication.SslProtocols.Tls11 |
|
||||
System.Security.Authentication.SslProtocols.Tls12;
|
||||
|
||||
|
@@ -1101,31 +1101,82 @@ namespace System.ServiceModel.Channels
|
||||
|
||||
|
||||
#if !FEATURE_CORECLR
|
||||
// On CoreCLR this is not the way to determine if a process is a tailored application (which means APPX).
|
||||
// On CoreCLR AppX is determined by a flag past to the host which is exposed by AppDomain.IsAppXProcess in mscorlib.
|
||||
// The reason for this if-def is to ensure nobody takes a dependency on this on CoreCLR.
|
||||
|
||||
private static IntPtr GetCurrentProcessToken() { return new IntPtr(-4); }
|
||||
|
||||
enum AppPolicyClrCompat
|
||||
{
|
||||
AppPolicyClrCompat_Others = 0,
|
||||
AppPolicyClrCompat_ClassicDesktop = 1,
|
||||
AppPolicyClrCompat_Universal = 2,
|
||||
AppPolicyClrCompat_PackagedDesktop = 3
|
||||
};
|
||||
|
||||
[DllImport(KERNEL32, CharSet = CharSet.None, EntryPoint = "AppPolicyGetClrCompat")]
|
||||
[System.Security.SecuritySafeCritical]
|
||||
[return: MarshalAs(UnmanagedType.I4)]
|
||||
private static extern Int32 _AppPolicyGetClrCompat(IntPtr processToken, out AppPolicyClrCompat appPolicyClrCompat);
|
||||
|
||||
// AppModel.h functions (Win8+)
|
||||
[DllImport(KERNEL32, CharSet = CharSet.None, EntryPoint = "GetCurrentPackageId")]
|
||||
[SecurityCritical]
|
||||
[System.Security.SecuritySafeCritical]
|
||||
[return: MarshalAs(UnmanagedType.I4)]
|
||||
private static extern Int32 GetCurrentPackageId(ref Int32 pBufferLength, Byte[] pBuffer);
|
||||
private static extern Int32 _GetCurrentPackageId(ref Int32 pBufferLength, Byte[] pBuffer);
|
||||
|
||||
[Fx.Tag.SecurityNote(
|
||||
Critical = "Critical because it calls the native function GetCurrentPackageId.",
|
||||
Safe = "Safe because it takes no user input and it doesn't leak security sensitive information.")]
|
||||
[SecuritySafeCritical]
|
||||
[DllImport(KERNEL32, CharSet=System.Runtime.InteropServices.CharSet.Auto, BestFitMapping=false)]
|
||||
[ResourceExposure(ResourceScope.Machine)]
|
||||
private static extern IntPtr GetModuleHandle(string modName);
|
||||
|
||||
// Copied from Win32Native.cs
|
||||
// Note - do NOT use this to call methods. Use P/Invoke, which will
|
||||
// do much better things w.r.t. marshaling, pinning memory, security
|
||||
// stuff, better interactions with thread aborts, etc. This is used
|
||||
// solely by DoesWin32MethodExist for avoiding try/catch EntryPointNotFoundException
|
||||
// in scenarios where an OS Version check is insufficient
|
||||
[DllImport(KERNEL32, CharSet=CharSet.Ansi, BestFitMapping=false, SetLastError=true, ExactSpelling=true)]
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
private static extern IntPtr GetProcAddress(IntPtr hModule, String methodName);
|
||||
|
||||
[System.Security.SecurityCritical] // auto-generated
|
||||
private static bool DoesWin32MethodExist(String moduleName, String methodName)
|
||||
{
|
||||
// GetModuleHandle does not increment the module's ref count, so we don't need to call FreeLibrary.
|
||||
IntPtr hModule = GetModuleHandle(moduleName);
|
||||
if (hModule == IntPtr.Zero) {
|
||||
System.Diagnostics.Debug.Assert(hModule != IntPtr.Zero, "GetModuleHandle failed. Dll isn't loaded?");
|
||||
return false;
|
||||
}
|
||||
IntPtr functionPointer = GetProcAddress(hModule, methodName);
|
||||
return (functionPointer != IntPtr.Zero);
|
||||
}
|
||||
|
||||
// On CoreCLR this is not the way to determine if a process is a tailored application (which means APPX).
|
||||
// On CoreCLR AppX is determined by a flag past to the host which is exposed by AppDomain.IsAppXProcess in mscorlib.
|
||||
// The reason for this if-def is to ensure nobody takes a dependency on this on CoreCLR.
|
||||
[System.Security.SecuritySafeCritical]
|
||||
private static bool _IsTailoredApplication()
|
||||
{
|
||||
if (OSEnvironmentHelper.IsAtLeast(OSVersion.Win8))
|
||||
Version windows8Version = new Version(6, 2, 0, 0);
|
||||
OperatingSystem os = Environment.OSVersion;
|
||||
bool osSupportsPackagedProcesses = os.Platform == PlatformID.Win32NT && os.Version >= windows8Version;
|
||||
|
||||
if (osSupportsPackagedProcesses && DoesWin32MethodExist(KERNEL32, "AppPolicyGetClrCompat"))
|
||||
{
|
||||
int bufLen = 0;
|
||||
// Will return ERROR_INSUFFICIENT_BUFFER when running within a tailored application,
|
||||
// Use AppPolicyGetClrCompat if it is available. Return true if and only if this is a UWA which means if
|
||||
// this is packaged desktop app this method will return false. This may cause some confusion however
|
||||
// this is necessary to make the behavior of packaged desktop apps identical to desktop apps.
|
||||
AppPolicyClrCompat appPolicyClrCompat;
|
||||
return _AppPolicyGetClrCompat(GetCurrentProcessToken(), out appPolicyClrCompat) == ERROR_SUCCESS &&
|
||||
appPolicyClrCompat == AppPolicyClrCompat.AppPolicyClrCompat_Universal;
|
||||
}
|
||||
else if(osSupportsPackagedProcesses && DoesWin32MethodExist(KERNEL32, "GetCurrentPackageId"))
|
||||
{
|
||||
Int32 bufLen = 0;
|
||||
// Will return ERROR_INSUFFICIENT_BUFFER when running within a packaged application,
|
||||
// and will return ERROR_NO_PACKAGE_IDENTITY otherwise.
|
||||
return GetCurrentPackageId(ref bufLen, null) == ERROR_INSUFFICIENT_BUFFER;
|
||||
return _GetCurrentPackageId(ref bufLen, null) == ERROR_INSUFFICIENT_BUFFER;
|
||||
}
|
||||
else
|
||||
{
|
||||
{ // We must be running on a downlevel OS.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ namespace System.ServiceModel.Channels
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@@ -44,6 +45,7 @@ namespace System.ServiceModel.Channels
|
||||
static readonly HashSet<char> InvalidSeparatorSet = new HashSet<char>(new char[] { '(', ')', '<', '>', '@', ',', ';', ':', '\\', '"', '/', '[', ']', '?', '=', '{', '}', ' ' });
|
||||
static string currentWebSocketVersion;
|
||||
|
||||
[SuppressMessage("Microsoft.Security.Cryptography", "CA5354:DoNotUseSHA1", Justification = "Cannot change. Usage of SHA1 is part of WebSocket spec. Justification in RFC6455 section 10.8")]
|
||||
internal static string ComputeAcceptHeader(string webSocketKey)
|
||||
{
|
||||
Fx.Assert(webSocketKey != null, "webSocketKey should not be null.");
|
||||
|
Reference in New Issue
Block a user