45
45
#define READ_OUT_SIZE (16 * KB_1)
46
46
#define READ_IN_SIZE READ_OUT_SIZE
47
47
#define EST_HANDSHAKE_SIZE (7 * KB_1)
48
- #define WINDOWS_BUILD_1809 1809
48
+ #define WINDOWS_BUILD_20348 20348
49
49
50
50
#define EST_TLS_RECORD_OVERHEAD 53 /* 5 byte header + 32 + 16 bytes for padding */
51
51
@@ -142,20 +142,21 @@ static size_t s_message_overhead(struct aws_channel_handler *handler) {
142
142
return sc_handler -> stream_sizes .cbTrailer + sc_handler -> stream_sizes .cbHeader ;
143
143
}
144
144
145
- /* Checks whether current system is running Windows 10 version `build_number` or later. This check is used
146
- to determin availability of TLS 1.3. This will continue to be a valid check in Windows 11 and later as the
147
- build number continues to increment upwards. e.g. Windows 11 starts at version 21H2 (build 22_000) */
148
- static bool s_is_windows_equal_or_above_version (DWORD build_number ) {
149
- ULONGLONG dwlConditionMask = 0 ;
150
- BYTE op = VER_GREATER_EQUAL ;
151
- OSVERSIONINFOEX osvi ;
152
-
145
+ /* Checks whether the current system is running Windows of a specific build number or later.
146
+ *
147
+ * This will continue to be a valid check in the future versions of Windows as the build number continues to increment
148
+ * upwards. E.g., Windows 10 last build number is 19045, and Windows 11 starts at 22000. */
149
+ static bool s_is_windows_equal_or_above_build_number (DWORD build_number ) {
153
150
NTSTATUS status = STATUS_DLL_NOT_FOUND ;
154
151
152
+ OSVERSIONINFOEX osvi ;
155
153
ZeroMemory (& osvi , sizeof (OSVERSIONINFOEX ));
154
+
156
155
osvi .dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX );
157
156
osvi .dwBuildNumber = build_number ;
158
157
158
+ ULONGLONG dwlConditionMask = 0 ;
159
+ BYTE op = VER_GREATER_EQUAL ;
159
160
dwlConditionMask = VerSetConditionMask (dwlConditionMask , VER_BUILDNUMBER , op );
160
161
typedef NTSTATUS (WINAPI * pRtlGetVersionInfo )(
161
162
OSVERSIONINFOEX * lpVersionInformation , ULONG TypeMask , ULONGLONG ConditionMask );
@@ -2142,8 +2143,10 @@ static DWORD s_get_enabled_protocols(enum aws_tls_versions minimum_tls_version,
2142
2143
return bit_enabled_protocols ;
2143
2144
}
2144
2145
2145
- static struct aws_channel_handler * s_tls_handler_sch_credentials_new (
2146
+ #if NTDDI_VERSION >= 0x0A000006 /* Windows SDK 10.1.17763.0 or later */
2146
2147
2148
+ /* The SCH_CREDENTIALS and few other structures became available starting with Windows SDK 10.1.17763.0. */
2149
+ static struct aws_channel_handler * s_tls_handler_sch_credentials_new (
2147
2150
struct aws_allocator * alloc ,
2148
2151
struct aws_tls_connection_options * options ,
2149
2152
struct aws_channel_slot * slot ,
@@ -2193,7 +2196,7 @@ static struct aws_channel_handler *s_tls_handler_sch_credentials_new(
2193
2196
& sc_handler -> sspi_timestamp );
2194
2197
2195
2198
if (status != SEC_E_OK ) {
2196
- AWS_LOGF_ERROR (AWS_LS_IO_TLS , "Error on AcquireCredentialsHandle. SECURITY_STATUS is %d " , (int )status );
2199
+ AWS_LOGF_ERROR (AWS_LS_IO_TLS , "Error on AcquireCredentialsHandle. SECURITY_STATUS is 0x%X " , (int )status );
2197
2200
int aws_error = s_determine_sspi_error (status );
2198
2201
aws_raise_error (aws_error );
2199
2202
goto on_error ;
@@ -2208,6 +2211,8 @@ static struct aws_channel_handler *s_tls_handler_sch_credentials_new(
2208
2211
return NULL ;
2209
2212
}
2210
2213
2214
+ #endif /* NTDDI_VERSION >= 0x0A000006 */
2215
+
2211
2216
static struct aws_channel_handler * s_tls_handler_schannel_cred_new (
2212
2217
struct aws_allocator * alloc ,
2213
2218
struct aws_tls_connection_options * options ,
@@ -2281,10 +2286,20 @@ static struct aws_channel_handler *s_tls_handler_new(
2281
2286
struct aws_channel_slot * slot ,
2282
2287
bool is_client_mode ) {
2283
2288
2284
- /* check if run on Windows 10 build 1809, (build 17_763) */
2285
- if (s_is_windows_equal_or_above_version (WINDOWS_BUILD_1809 ) && !s_use_schannel_creds ) {
2289
+ #if NTDDI_VERSION >= 0x0A000006 /* Windows SDK 10.1.17763.0 or later */
2290
+ /* This check is used to determine the availability of TLS 1.3. According to Microsoft documentation
2291
+ * (https://learn.microsoft.com/en-us/windows/win32/secauthn/protocols-in-tls-ssl--schannel-ssp-), TLS 1.3 became
2292
+ * available in Windows Server 2022 (build number 20348) and Windows 11, version 21H2 (build number 22000).
2293
+ *
2294
+ * For more information see also the following links with Windows releases:
2295
+ * - https://learn.microsoft.com/en-us/windows/release-health/release-information
2296
+ * - https://learn.microsoft.com/en-us/windows/release-health/windows11-release-information
2297
+ * - https://learn.microsoft.com/en-us/windows/release-health/windows-server-release-info
2298
+ */
2299
+ if (s_is_windows_equal_or_above_build_number (WINDOWS_BUILD_20348 ) && !s_use_schannel_creds ) {
2286
2300
return s_tls_handler_sch_credentials_new (alloc , options , slot , is_client_mode );
2287
2301
}
2302
+ #endif
2288
2303
return s_tls_handler_schannel_cred_new (alloc , options , slot , is_client_mode );
2289
2304
}
2290
2305
0 commit comments