|
49 | 49 | # define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 0x00000800 |
50 | 50 | #endif |
51 | 51 |
|
| 52 | +#ifndef WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3 |
| 53 | +# define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3 0x00002000 |
| 54 | +#endif |
| 55 | + |
52 | 56 | #ifndef HTTP_STATUS_PERMANENT_REDIRECT |
53 | 57 | # define HTTP_STATUS_PERMANENT_REDIRECT 308 |
54 | 58 | #endif |
@@ -743,7 +747,8 @@ static int winhttp_connect( |
743 | 747 | DWORD protocols = |
744 | 748 | WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 | |
745 | 749 | WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 | |
746 | | - WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2; |
| 750 | + WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 | |
| 751 | + WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3; |
747 | 752 |
|
748 | 753 | t->session = NULL; |
749 | 754 | t->connection = NULL; |
@@ -788,14 +793,20 @@ static int winhttp_connect( |
788 | 793 | } |
789 | 794 |
|
790 | 795 | /* |
791 | | - * Do a best-effort attempt to enable TLS 1.2 but allow this to |
792 | | - * fail; if TLS 1.2 support is not available for some reason, |
| 796 | + * Do a best-effort attempt to enable TLS 1.3 and 1.2 but allow this to |
| 797 | + * fail; if TLS 1.2 or 1.3 support is not available for some reason, |
793 | 798 | * ignore the failure (it will keep the default protocols). |
794 | 799 | */ |
795 | | - WinHttpSetOption(t->session, |
| 800 | + if (WinHttpSetOption(t->session, |
796 | 801 | WINHTTP_OPTION_SECURE_PROTOCOLS, |
797 | 802 | &protocols, |
798 | | - sizeof(protocols)); |
| 803 | + sizeof(protocols)) == FALSE) { |
| 804 | + protocols &= ~WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3; |
| 805 | + WinHttpSetOption(t->session, |
| 806 | + WINHTTP_OPTION_SECURE_PROTOCOLS, |
| 807 | + &protocols, |
| 808 | + sizeof(protocols)); |
| 809 | + } |
799 | 810 |
|
800 | 811 | if (!WinHttpSetTimeouts(t->session, default_timeout, default_connect_timeout, default_timeout, default_timeout)) { |
801 | 812 | git_error_set(GIT_ERROR_OS, "failed to set timeouts for WinHTTP"); |
|
0 commit comments