Skip to content

Commit 9bfad74

Browse files
authored
Merge pull request libgit2#6533 from libgit2/ethomson/schannel-2
Introduce Schannel and SSPI for Windows
2 parents c058aa8 + f15c8ac commit 9bfad74

33 files changed

+1453
-248
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,19 @@ jobs:
130130
SKIP_SSH_TESTS: true
131131
SKIP_NEGOTIATE_TESTS: true
132132
setup-script: osx
133-
- name: "Windows (amd64, Visual Studio)"
133+
- name: "Windows (amd64, Visual Studio, Schannel)"
134134
id: windows-amd64-vs
135135
os: windows-2019
136136
setup-script: win32
137137
env:
138138
ARCH: amd64
139139
CMAKE_GENERATOR: Visual Studio 16 2019
140-
CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_SSH=ON -DCMAKE_PREFIX_PATH=D:\Temp\libssh2
140+
CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_HTTPS=Schannel -DUSE_SSH=ON -DCMAKE_PREFIX_PATH=D:\Temp\libssh2
141141
BUILD_PATH: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin;D:\Temp\libssh2\bin
142142
BUILD_TEMP: D:\Temp
143143
SKIP_SSH_TESTS: true
144144
SKIP_NEGOTIATE_TESTS: true
145-
- name: "Windows (x86, Visual Studio)"
145+
- name: "Windows (x86, Visual Studio, WinHTTP)"
146146
id: windows-x86-vs
147147
os: windows-2019
148148
setup-script: win32
@@ -154,7 +154,7 @@ jobs:
154154
BUILD_TEMP: D:\Temp
155155
SKIP_SSH_TESTS: true
156156
SKIP_NEGOTIATE_TESTS: true
157-
- name: "Windows (amd64, mingw)"
157+
- name: "Windows (amd64, mingw, WinHTTP)"
158158
id: windows-amd64-mingw
159159
os: windows-2019
160160
setup-script: mingw
@@ -166,14 +166,14 @@ jobs:
166166
BUILD_PATH: D:\Temp\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
167167
SKIP_SSH_TESTS: true
168168
SKIP_NEGOTIATE_TESTS: true
169-
- name: "Windows (x86, mingw)"
169+
- name: "Windows (x86, mingw, Schannel)"
170170
id: windows-x86-mingw
171171
os: windows-2019
172172
setup-script: mingw
173173
env:
174174
ARCH: x86
175175
CMAKE_GENERATOR: MinGW Makefiles
176-
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
176+
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON -DUSE_HTTPS=Schannel
177177
BUILD_TEMP: D:\Temp
178178
BUILD_PATH: D:\Temp\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
179179
SKIP_SSH_TESTS: true

.github/workflows/nightly.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,32 +162,39 @@ jobs:
162162
SKIP_SSH_TESTS: true
163163
SKIP_NEGOTIATE_TESTS: true
164164
setup-script: osx
165-
- name: "Windows (amd64, Visual Studio)"
165+
- name: "Windows (amd64, Visual Studio, WinHTTP)"
166166
os: windows-2019
167167
env:
168168
ARCH: amd64
169169
CMAKE_GENERATOR: Visual Studio 16 2019
170-
CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON
170+
CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_HTTPS=WinHTTP
171171
SKIP_SSH_TESTS: true
172172
SKIP_NEGOTIATE_TESTS: true
173-
- name: "Windows (no mmap)"
173+
- name: "Windows (x86, Visual Studio, WinHTTP)"
174+
os: windows-2019
175+
env:
176+
ARCH: x86
177+
CMAKE_GENERATOR: Visual Studio 16 2019
178+
CMAKE_OPTIONS: -A Win32 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_HTTPS=WinHTTP -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON
179+
SKIP_SSH_TESTS: true
180+
SKIP_NEGOTIATE_TESTS: true
181+
- name: "Windows (amd64, Visual Studio, Schannel)"
174182
os: windows-2019
175183
env:
176184
ARCH: amd64
177185
CMAKE_GENERATOR: Visual Studio 16 2019
178-
CFLAGS: -DNO_MMAP
179-
CMAKE_OPTIONS: -A x64 -DDEPRECATE_HARD=ON
186+
CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_HTTPS=Schannel
180187
SKIP_SSH_TESTS: true
181188
SKIP_NEGOTIATE_TESTS: true
182-
- name: "Windows (x86, Visual Studio)"
189+
- name: "Windows (x86, Visual Studio, Schannel)"
183190
os: windows-2019
184191
env:
185192
ARCH: x86
186193
CMAKE_GENERATOR: Visual Studio 16 2019
187-
CMAKE_OPTIONS: -A Win32 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON
194+
CMAKE_OPTIONS: -A Win32 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_HTTPS=Schannel -DUSE_BUNDLED_ZLIB=ON
188195
SKIP_SSH_TESTS: true
189196
SKIP_NEGOTIATE_TESTS: true
190-
- name: "Windows (amd64, mingw)"
197+
- name: "Windows (amd64, mingw, WinHTTP)"
191198
os: windows-2019
192199
setup-script: mingw
193200
env:
@@ -198,17 +205,26 @@ jobs:
198205
BUILD_PATH: D:\Temp\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
199206
SKIP_SSH_TESTS: true
200207
SKIP_NEGOTIATE_TESTS: true
201-
- name: "Windows (x86, mingw)"
208+
- name: "Windows (x86, mingw, Schannel)"
202209
os: windows-2019
203210
setup-script: mingw
204211
env:
205212
ARCH: x86
206213
CMAKE_GENERATOR: MinGW Makefiles
207-
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
214+
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON -DUSE_HTTPS=Schannel
208215
BUILD_TEMP: D:\Temp
209216
BUILD_PATH: D:\Temp\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
210217
SKIP_SSH_TESTS: true
211218
SKIP_NEGOTIATE_TESTS: true
219+
- name: "Windows (no mmap)"
220+
os: windows-2019
221+
env:
222+
ARCH: amd64
223+
CMAKE_GENERATOR: Visual Studio 16 2019
224+
CFLAGS: -DNO_MMAP
225+
CMAKE_OPTIONS: -A x64 -DDEPRECATE_HARD=ON
226+
SKIP_SSH_TESTS: true
227+
SKIP_NEGOTIATE_TESTS: true
212228
- name: "Linux (Bionic, GCC, dynamically-loaded OpenSSL)"
213229
container:
214230
name: bionic

CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ if(MSVC)
8282
option(WIN32_LEAKCHECK "Enable leak reporting via crtdbg" OFF)
8383
endif()
8484

85-
if(WIN32)
86-
# By default, libgit2 is built with WinHTTP. To use the built-in
87-
# HTTP transport, invoke CMake with the "-DUSE_WINHTTP=OFF" argument.
88-
option(USE_WINHTTP "Use Win32 WinHTTP routines" ON)
89-
endif()
90-
9185
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
9286
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
9387
endif()

cmake/SelectGSSAPI.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if(USE_GSSAPI)
2929
list(APPEND LIBGIT2_SYSTEM_LIBS ${GSSFRAMEWORK_LIBRARIES})
3030

3131
set(GIT_GSSFRAMEWORK 1)
32-
add_feature_info(SPNEGO GIT_GSSFRAMEWORK "SPNEGO authentication support (${USE_GSSAPI})")
32+
add_feature_info(GSSAPI GIT_GSSFRAMEWORK "GSSAPI support for SPNEGO authentication (${USE_GSSAPI})")
3333
elseif(USE_GSSAPI STREQUAL "gssapi")
3434
if(NOT GSSAPI_FOUND)
3535
message(FATAL_ERROR "Asked for gssapi GSS backend, but it wasn't found")
@@ -38,11 +38,11 @@ if(USE_GSSAPI)
3838
list(APPEND LIBGIT2_SYSTEM_LIBS ${GSSAPI_LIBRARIES})
3939

4040
set(GIT_GSSAPI 1)
41-
add_feature_info(SPNEGO GIT_GSSAPI "SPNEGO authentication support (${USE_GSSAPI})")
41+
add_feature_info(GSSAPI GIT_GSSAPI "GSSAPI support for SPNEGO authentication (${USE_GSSAPI})")
4242
else()
4343
message(FATAL_ERROR "Asked for backend ${USE_GSSAPI} but it wasn't found")
4444
endif()
4545
else()
4646
set(GIT_GSSAPI 0)
47-
add_feature_info(SPNEGO NO "SPNEGO authentication support")
47+
add_feature_info(GSSAPI NO "GSSAPI support for SPNEGO authentication")
4848
endif()

cmake/SelectHTTPSBackend.cmake

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if(USE_HTTPS)
1919
message(STATUS "Security framework is too old, falling back to OpenSSL")
2020
set(USE_HTTPS "OpenSSL")
2121
endif()
22-
elseif(USE_WINHTTP)
22+
elseif(WIN32)
2323
set(USE_HTTPS "WinHTTP")
2424
elseif(OPENSSL_FOUND)
2525
set(USE_HTTPS "OpenSSL")
@@ -106,8 +106,27 @@ if(USE_HTTPS)
106106
# https://github.com/ARMmbed/mbedtls/issues/228
107107
# For now, pass its link flags as our own
108108
list(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
109+
elseif(USE_HTTPS STREQUAL "Schannel")
110+
set(GIT_SCHANNEL 1)
111+
112+
list(APPEND LIBGIT2_SYSTEM_LIBS "rpcrt4" "crypt32" "ole32" "secur32")
113+
list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32" "-lsecur32")
109114
elseif(USE_HTTPS STREQUAL "WinHTTP")
110-
# WinHTTP setup was handled in the WinHTTP-specific block above
115+
set(GIT_WINHTTP 1)
116+
117+
# Since MinGW does not come with headers or an import library for winhttp,
118+
# we have to include a private header and generate our own import library
119+
if(MINGW)
120+
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/winhttp" "${PROJECT_BINARY_DIR}/deps/winhttp")
121+
list(APPEND LIBGIT2_SYSTEM_LIBS winhttp)
122+
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/winhttp")
123+
else()
124+
list(APPEND LIBGIT2_SYSTEM_LIBS "winhttp")
125+
list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
126+
endif()
127+
128+
list(APPEND LIBGIT2_SYSTEM_LIBS "rpcrt4" "crypt32" "ole32" "secur32")
129+
list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32" "-lsecur32")
111130
elseif(USE_HTTPS STREQUAL "OpenSSL-Dynamic")
112131
set(GIT_OPENSSL 1)
113132
set(GIT_OPENSSL_DYNAMIC 1)

cmake/SelectHashes.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ if(USE_SHA1 STREQUAL ON)
1313
elseif(USE_SHA1 STREQUAL "HTTPS")
1414
if(USE_HTTPS STREQUAL "SecureTransport")
1515
set(USE_SHA1 "CommonCrypto")
16+
elseif(USE_HTTPS STREQUAL "Schannel")
17+
set(USE_SHA1 "Win32")
1618
elseif(USE_HTTPS STREQUAL "WinHTTP")
1719
set(USE_SHA1 "Win32")
1820
elseif(USE_HTTPS)
@@ -51,6 +53,8 @@ endif()
5153
if(USE_SHA256 STREQUAL "HTTPS")
5254
if(USE_HTTPS STREQUAL "SecureTransport")
5355
set(USE_SHA256 "CommonCrypto")
56+
elseif(USE_HTTPS STREQUAL "Schannel")
57+
set(USE_SHA256 "Win32")
5458
elseif(USE_HTTPS STREQUAL "WinHTTP")
5559
set(USE_SHA256 "Win32")
5660
elseif(USE_HTTPS)

cmake/SelectWinHTTP.cmake

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ include(SelectHashes)
4242
include(SelectHTTPParser)
4343
include(SelectRegex)
4444
include(SelectSSH)
45-
include(SelectWinHTTP)
4645
include(SelectZlib)
4746

4847
#

src/libgit2/libgit2.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "streams/registry.h"
3131
#include "streams/mbedtls.h"
3232
#include "streams/openssl.h"
33+
#include "streams/socket.h"
3334
#include "transports/smart.h"
3435
#include "transports/http.h"
3536
#include "transports/ssh.h"
@@ -78,6 +79,7 @@ int git_libgit2_init(void)
7879
git_merge_driver_global_init,
7980
git_transport_ssh_global_init,
8081
git_stream_registry_global_init,
82+
git_socket_stream_global_init,
8183
git_openssl_stream_global_init,
8284
git_mbedtls_stream_global_init,
8385
git_mwindow_global_init,

0 commit comments

Comments
 (0)