Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,10 @@ private static IntPtr GetSslMethod(SslProtocols protocols)
{
Debug.Assert(protocols != SslProtocols.None, "All protocols are disabled");

#pragma warning disable 0618 // Ssl2, Ssl3 are deprecated.
bool ssl2 = (protocols & SslProtocols.Ssl2) == SslProtocols.Ssl2;
bool ssl3 = (protocols & SslProtocols.Ssl3) == SslProtocols.Ssl3;
#pragma warning restore
bool tls10 = (protocols & SslProtocols.Tls) == SslProtocols.Tls;
bool tls11 = (protocols & SslProtocols.Tls11) == SslProtocols.Tls11;
bool tls12 = (protocols & SslProtocols.Tls12) == SslProtocols.Tls12;
Expand Down
66 changes: 66 additions & 0 deletions src/Common/src/Interop/Windows/SChannel/Interop.Alerts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// 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.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class SChannel
{
// schannel.h;

//
//
// ApplyControlToken PkgParams types
//
// These identifiers are the DWORD types
// to be passed into ApplyControlToken
// through a PkgParams buffer.

public const int SCHANNEL_RENEGOTIATE = 0; // renegotiate a connection
public const int SCHANNEL_SHUTDOWN = 1; // gracefully close down a connection
public const int SCHANNEL_ALERT = 2; // build an error message
public const int SCHANNEL_SESSION = 3; // session control


// Alert token structure.
[StructLayout(LayoutKind.Sequential)]
public struct SCHANNEL_ALERT_TOKEN
{
public uint dwTokenType; // SCHANNEL_ALERT
public uint dwAlertType;
public uint dwAlertNumber;
}

// Alert types.
public const int TLS1_ALERT_WARNING = 1;
public const int TLS1_ALERT_FATAL = 2;

// Alert messages.
public const int TLS1_ALERT_CLOSE_NOTIFY = 0; // warning
public const int TLS1_ALERT_UNEXPECTED_MESSAGE = 10; // error
public const int TLS1_ALERT_BAD_RECORD_MAC = 20; // error
public const int TLS1_ALERT_DECRYPTION_FAILED = 21; // reserved
public const int TLS1_ALERT_RECORD_OVERFLOW = 22; // error
public const int TLS1_ALERT_DECOMPRESSION_FAIL = 30; // error
public const int TLS1_ALERT_HANDSHAKE_FAILURE = 40; // error
public const int TLS1_ALERT_BAD_CERTIFICATE = 42; // warning or error
public const int TLS1_ALERT_UNSUPPORTED_CERT = 43; // warning or error
public const int TLS1_ALERT_CERTIFICATE_REVOKED = 44; // warning or error
public const int TLS1_ALERT_CERTIFICATE_EXPIRED = 45; // warning or error
public const int TLS1_ALERT_CERTIFICATE_UNKNOWN = 46; // warning or error
public const int TLS1_ALERT_ILLEGAL_PARAMETER = 47; // error
public const int TLS1_ALERT_UNKNOWN_CA = 48; // error
public const int TLS1_ALERT_ACCESS_DENIED = 49; // error
public const int TLS1_ALERT_DECODE_ERROR = 50; // error
public const int TLS1_ALERT_DECRYPT_ERROR = 51; // error
public const int TLS1_ALERT_EXPORT_RESTRICTION = 60; // reserved
public const int TLS1_ALERT_PROTOCOL_VERSION = 70; // error
public const int TLS1_ALERT_INSUFFIENT_SECURITY = 71; // error
public const int TLS1_ALERT_INTERNAL_ERROR = 80; // error
public const int TLS1_ALERT_USER_CANCELED = 90; // warning or error
public const int TLS1_ALERT_NO_RENEGOTIATION = 100; // warning
public const int TLS1_ALERT_UNSUPPORTED_EXT = 110; // error
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

internal static partial class Interop
{
internal enum SecurityStatus
internal enum SECURITY_STATUS
{
// Success / Informational
OK = 0x00000000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

namespace System.Net
{
// TODO (Issue #3114): Move to Interop.
// Investigate if this can be safely converted to a struct.
// TODO (Issue #3114): Investigate if this can be safely converted to a struct.
// From Schannel.h
[StructLayout(LayoutKind.Sequential)]
internal class SslConnectionInfo
internal class SecPkgContext_ConnectionInfo
{
public readonly int Protocol;
public readonly int DataCipherAlg;
Expand All @@ -21,7 +20,7 @@ internal class SslConnectionInfo
public readonly int KeyExchangeAlg;
public readonly int KeyExchKeySize;

internal unsafe SslConnectionInfo(byte[] nativeBuffer)
internal unsafe SecPkgContext_ConnectionInfo(byte[] nativeBuffer)
{
fixed (void* voidPtr = nativeBuffer)
{
Expand Down
Loading