Commit f68f542e by Edward Thomson Committed by Edward Thomson

http: introduce schannel streams for windows

Provide a stream interface for Schannel - the native crypto APIs - on
Windows. This allows Windows to use the same HTTP transport that all the
other platforms use, with its own native crypto.

Ultimately this allows us to deprecate WinHTTP and we need not add
support for our socket changes in two places (our HTTP stack and the
WinHTTP stack).
parent 1b929b3d
...@@ -130,19 +130,19 @@ jobs: ...@@ -130,19 +130,19 @@ jobs:
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
setup-script: osx setup-script: osx
- name: "Windows (amd64, Visual Studio)" - name: "Windows (amd64, Visual Studio, Schannel)"
id: windows-amd64-vs id: windows-amd64-vs
os: windows-2019 os: windows-2019
setup-script: win32 setup-script: win32
env: env:
ARCH: amd64 ARCH: amd64
CMAKE_GENERATOR: Visual Studio 16 2019 CMAKE_GENERATOR: Visual Studio 16 2019
CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_SSH=ON -DCMAKE_PREFIX_PATH=D:\Temp\libssh2 CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_HTTPS=Schannel -DUSE_SSH=ON -DCMAKE_PREFIX_PATH=D:\Temp\libssh2
BUILD_PATH: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin;D:\Temp\libssh2\bin BUILD_PATH: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin;D:\Temp\libssh2\bin
BUILD_TEMP: D:\Temp BUILD_TEMP: D:\Temp
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
- name: "Windows (x86, Visual Studio)" - name: "Windows (x86, Visual Studio, WinHTTP)"
id: windows-x86-vs id: windows-x86-vs
os: windows-2019 os: windows-2019
setup-script: win32 setup-script: win32
...@@ -154,7 +154,7 @@ jobs: ...@@ -154,7 +154,7 @@ jobs:
BUILD_TEMP: D:\Temp BUILD_TEMP: D:\Temp
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
- name: "Windows (amd64, mingw)" - name: "Windows (amd64, mingw, WinHTTP)"
id: windows-amd64-mingw id: windows-amd64-mingw
os: windows-2019 os: windows-2019
setup-script: mingw setup-script: mingw
...@@ -166,14 +166,14 @@ jobs: ...@@ -166,14 +166,14 @@ jobs:
BUILD_PATH: D:\Temp\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin BUILD_PATH: D:\Temp\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
- name: "Windows (x86, mingw)" - name: "Windows (x86, mingw, Schannel)"
id: windows-x86-mingw id: windows-x86-mingw
os: windows-2019 os: windows-2019
setup-script: mingw setup-script: mingw
env: env:
ARCH: x86 ARCH: x86
CMAKE_GENERATOR: MinGW Makefiles CMAKE_GENERATOR: MinGW Makefiles
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON CMAKE_OPTIONS: -DDEPRECATE_HARD=ON -DUSE_HTTPS=Schannel
BUILD_TEMP: D:\Temp BUILD_TEMP: D:\Temp
BUILD_PATH: D:\Temp\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin BUILD_PATH: D:\Temp\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
......
...@@ -162,32 +162,39 @@ jobs: ...@@ -162,32 +162,39 @@ jobs:
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
setup-script: osx setup-script: osx
- name: "Windows (amd64, Visual Studio)" - name: "Windows (amd64, Visual Studio, WinHTTP)"
os: windows-2019 os: windows-2019
env: env:
ARCH: amd64 ARCH: amd64
CMAKE_GENERATOR: Visual Studio 16 2019 CMAKE_GENERATOR: Visual Studio 16 2019
CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_HTTPS=WinHTTP
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
- name: "Windows (no mmap)" - name: "Windows (x86, Visual Studio, WinHTTP)"
os: windows-2019
env:
ARCH: x86
CMAKE_GENERATOR: Visual Studio 16 2019
CMAKE_OPTIONS: -A Win32 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_HTTPS=WinHTTP -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON
SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true
- name: "Windows (amd64, Visual Studio, Schannel)"
os: windows-2019 os: windows-2019
env: env:
ARCH: amd64 ARCH: amd64
CMAKE_GENERATOR: Visual Studio 16 2019 CMAKE_GENERATOR: Visual Studio 16 2019
CFLAGS: -DNO_MMAP CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_HTTPS=Schannel
CMAKE_OPTIONS: -A x64 -DDEPRECATE_HARD=ON
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
- name: "Windows (x86, Visual Studio)" - name: "Windows (x86, Visual Studio, Schannel)"
os: windows-2019 os: windows-2019
env: env:
ARCH: x86 ARCH: x86
CMAKE_GENERATOR: Visual Studio 16 2019 CMAKE_GENERATOR: Visual Studio 16 2019
CMAKE_OPTIONS: -A Win32 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON CMAKE_OPTIONS: -A Win32 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_HTTPS=Schannel -DUSE_BUNDLED_ZLIB=ON
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
- name: "Windows (amd64, mingw)" - name: "Windows (amd64, mingw, WinHTTP)"
os: windows-2019 os: windows-2019
setup-script: mingw setup-script: mingw
env: env:
...@@ -198,17 +205,26 @@ jobs: ...@@ -198,17 +205,26 @@ jobs:
BUILD_PATH: D:\Temp\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin BUILD_PATH: D:\Temp\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
- name: "Windows (x86, mingw)" - name: "Windows (x86, mingw, Schannel)"
os: windows-2019 os: windows-2019
setup-script: mingw setup-script: mingw
env: env:
ARCH: x86 ARCH: x86
CMAKE_GENERATOR: MinGW Makefiles CMAKE_GENERATOR: MinGW Makefiles
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON CMAKE_OPTIONS: -DDEPRECATE_HARD=ON -DUSE_HTTPS=Schannel
BUILD_TEMP: D:\Temp BUILD_TEMP: D:\Temp
BUILD_PATH: D:\Temp\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin BUILD_PATH: D:\Temp\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
- name: "Windows (no mmap)"
os: windows-2019
env:
ARCH: amd64
CMAKE_GENERATOR: Visual Studio 16 2019
CFLAGS: -DNO_MMAP
CMAKE_OPTIONS: -A x64 -DDEPRECATE_HARD=ON
SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true
- name: "Linux (Bionic, GCC, dynamically-loaded OpenSSL)" - name: "Linux (Bionic, GCC, dynamically-loaded OpenSSL)"
container: container:
name: bionic name: bionic
......
...@@ -82,12 +82,6 @@ if(MSVC) ...@@ -82,12 +82,6 @@ if(MSVC)
option(WIN32_LEAKCHECK "Enable leak reporting via crtdbg" OFF) option(WIN32_LEAKCHECK "Enable leak reporting via crtdbg" OFF)
endif() endif()
if(WIN32)
# By default, libgit2 is built with WinHTTP. To use the built-in
# HTTP transport, invoke CMake with the "-DUSE_WINHTTP=OFF" argument.
option(USE_WINHTTP "Use Win32 WinHTTP routines" ON)
endif()
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif() endif()
......
...@@ -19,7 +19,7 @@ if(USE_HTTPS) ...@@ -19,7 +19,7 @@ if(USE_HTTPS)
message(STATUS "Security framework is too old, falling back to OpenSSL") message(STATUS "Security framework is too old, falling back to OpenSSL")
set(USE_HTTPS "OpenSSL") set(USE_HTTPS "OpenSSL")
endif() endif()
elseif(USE_WINHTTP) elseif(WIN32)
set(USE_HTTPS "WinHTTP") set(USE_HTTPS "WinHTTP")
elseif(OPENSSL_FOUND) elseif(OPENSSL_FOUND)
set(USE_HTTPS "OpenSSL") set(USE_HTTPS "OpenSSL")
...@@ -106,8 +106,27 @@ if(USE_HTTPS) ...@@ -106,8 +106,27 @@ if(USE_HTTPS)
# https://github.com/ARMmbed/mbedtls/issues/228 # https://github.com/ARMmbed/mbedtls/issues/228
# For now, pass its link flags as our own # For now, pass its link flags as our own
list(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES}) list(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
elseif(USE_HTTPS STREQUAL "Schannel")
set(GIT_SCHANNEL 1)
list(APPEND LIBGIT2_SYSTEM_LIBS "rpcrt4" "crypt32" "ole32" "secur32")
list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32" "-lsecur32")
elseif(USE_HTTPS STREQUAL "WinHTTP") elseif(USE_HTTPS STREQUAL "WinHTTP")
# WinHTTP setup was handled in the WinHTTP-specific block above set(GIT_WINHTTP 1)
# Since MinGW does not come with headers or an import library for winhttp,
# we have to include a private header and generate our own import library
if(MINGW)
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/winhttp" "${PROJECT_BINARY_DIR}/deps/winhttp")
list(APPEND LIBGIT2_SYSTEM_LIBS winhttp)
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/winhttp")
else()
list(APPEND LIBGIT2_SYSTEM_LIBS "winhttp")
list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
endif()
list(APPEND LIBGIT2_SYSTEM_LIBS "rpcrt4" "crypt32" "ole32")
list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
elseif(USE_HTTPS STREQUAL "OpenSSL-Dynamic") elseif(USE_HTTPS STREQUAL "OpenSSL-Dynamic")
set(GIT_OPENSSL 1) set(GIT_OPENSSL 1)
set(GIT_OPENSSL_DYNAMIC 1) set(GIT_OPENSSL_DYNAMIC 1)
......
...@@ -13,6 +13,8 @@ if(USE_SHA1 STREQUAL ON) ...@@ -13,6 +13,8 @@ if(USE_SHA1 STREQUAL ON)
elseif(USE_SHA1 STREQUAL "HTTPS") elseif(USE_SHA1 STREQUAL "HTTPS")
if(USE_HTTPS STREQUAL "SecureTransport") if(USE_HTTPS STREQUAL "SecureTransport")
set(USE_SHA1 "CommonCrypto") set(USE_SHA1 "CommonCrypto")
elseif(USE_HTTPS STREQUAL "Schannel")
set(USE_SHA1 "Win32")
elseif(USE_HTTPS STREQUAL "WinHTTP") elseif(USE_HTTPS STREQUAL "WinHTTP")
set(USE_SHA1 "Win32") set(USE_SHA1 "Win32")
elseif(USE_HTTPS) elseif(USE_HTTPS)
...@@ -51,6 +53,8 @@ endif() ...@@ -51,6 +53,8 @@ endif()
if(USE_SHA256 STREQUAL "HTTPS") if(USE_SHA256 STREQUAL "HTTPS")
if(USE_HTTPS STREQUAL "SecureTransport") if(USE_HTTPS STREQUAL "SecureTransport")
set(USE_SHA256 "CommonCrypto") set(USE_SHA256 "CommonCrypto")
elseif(USE_HTTPS STREQUAL "Schannel")
set(USE_SHA256 "Win32")
elseif(USE_HTTPS STREQUAL "WinHTTP") elseif(USE_HTTPS STREQUAL "WinHTTP")
set(USE_SHA256 "Win32") set(USE_SHA256 "Win32")
elseif(USE_HTTPS) elseif(USE_HTTPS)
......
if(WIN32 AND USE_WINHTTP)
set(GIT_WINHTTP 1)
# Since MinGW does not come with headers or an import library for winhttp,
# we have to include a private header and generate our own import library
if(MINGW)
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/winhttp" "${PROJECT_BINARY_DIR}/deps/winhttp")
list(APPEND LIBGIT2_SYSTEM_LIBS winhttp)
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/winhttp")
else()
list(APPEND LIBGIT2_SYSTEM_LIBS "winhttp")
list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
endif()
list(APPEND LIBGIT2_SYSTEM_LIBS "rpcrt4" "crypt32" "ole32")
list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
endif()
...@@ -42,7 +42,6 @@ include(SelectHashes) ...@@ -42,7 +42,6 @@ include(SelectHashes)
include(SelectHTTPParser) include(SelectHTTPParser)
include(SelectRegex) include(SelectRegex)
include(SelectSSH) include(SelectSSH)
include(SelectWinHTTP)
include(SelectZlib) include(SelectZlib)
# #
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "streams/registry.h" #include "streams/registry.h"
#include "streams/mbedtls.h" #include "streams/mbedtls.h"
#include "streams/openssl.h" #include "streams/openssl.h"
#include "streams/socket.h"
#include "transports/smart.h" #include "transports/smart.h"
#include "transports/http.h" #include "transports/http.h"
#include "transports/ssh.h" #include "transports/ssh.h"
...@@ -78,6 +79,7 @@ int git_libgit2_init(void) ...@@ -78,6 +79,7 @@ int git_libgit2_init(void)
git_merge_driver_global_init, git_merge_driver_global_init,
git_transport_ssh_global_init, git_transport_ssh_global_init,
git_stream_registry_global_init, git_stream_registry_global_init,
git_socket_stream_global_init,
git_openssl_stream_global_init, git_openssl_stream_global_init,
git_mbedtls_stream_global_init, git_mbedtls_stream_global_init,
git_mwindow_global_init, git_mwindow_global_init,
......
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#ifndef INCLUDE_steams_schannel_h__
#define INCLUDE_steams_schannel_h__
#include "common.h"
#include "git2/sys/stream.h"
#ifdef GIT_SCHANNEL
extern int git_schannel_stream_new(
git_stream **out,
const char *host,
const char *port);
extern int git_schannel_stream_wrap(
git_stream **out,
git_stream *in,
const char *host);
#endif
#endif
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "posix.h" #include "posix.h"
#include "netops.h" #include "netops.h"
#include "registry.h" #include "registry.h"
#include "runtime.h"
#include "stream.h" #include "stream.h"
#ifndef _WIN32 #ifndef _WIN32
...@@ -54,11 +55,8 @@ static int close_socket(GIT_SOCKET s) ...@@ -54,11 +55,8 @@ static int close_socket(GIT_SOCKET s)
return 0; return 0;
#ifdef GIT_WIN32 #ifdef GIT_WIN32
if (SOCKET_ERROR == closesocket(s)) if (closesocket(s) != 0) {
return -1; net_set_error("could not close socket");
if (0 != WSACleanup()) {
git_error_set(GIT_ERROR_OS, "winsock cleanup failed");
return -1; return -1;
} }
...@@ -77,23 +75,6 @@ static int socket_connect(git_stream *stream) ...@@ -77,23 +75,6 @@ static int socket_connect(git_stream *stream)
GIT_SOCKET s = INVALID_SOCKET; GIT_SOCKET s = INVALID_SOCKET;
int ret; int ret;
#ifdef GIT_WIN32
/* on win32, the WSA context needs to be initialized
* before any socket calls can be performed */
WSADATA wsd;
if (WSAStartup(MAKEWORD(2,2), &wsd) != 0) {
git_error_set(GIT_ERROR_OS, "winsock init failed");
return -1;
}
if (LOBYTE(wsd.wVersion) != 2 || HIBYTE(wsd.wVersion) != 2) {
WSACleanup();
git_error_set(GIT_ERROR_OS, "winsock init failed");
return -1;
}
#endif
memset(&hints, 0x0, sizeof(struct addrinfo)); memset(&hints, 0x0, sizeof(struct addrinfo));
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
hints.ai_family = AF_UNSPEC; hints.ai_family = AF_UNSPEC;
...@@ -240,3 +221,42 @@ int git_socket_stream_new( ...@@ -240,3 +221,42 @@ int git_socket_stream_new(
return init(out, host, port); return init(out, host, port);
} }
#ifdef GIT_WIN32
static void socket_stream_global_shutdown(void)
{
WSACleanup();
}
int git_socket_stream_global_init(void)
{
WORD winsock_version;
WSADATA wsa_data;
winsock_version = MAKEWORD(2, 2);
if (WSAStartup(winsock_version, &wsa_data) != 0) {
git_error_set(GIT_ERROR_OS, "could not initialize Windows Socket Library");
return -1;
}
if (LOBYTE(wsa_data.wVersion) != 2 ||
HIBYTE(wsa_data.wVersion) != 2) {
git_error_set(GIT_ERROR_SSL, "Windows Socket Library does not support Winsock 2.2");
return -1;
}
return git_runtime_shutdown_register(socket_stream_global_shutdown);
}
#else
#include "stream.h"
int git_socket_stream_global_init(void)
{
return 0;
}
#endif
...@@ -20,4 +20,6 @@ typedef struct { ...@@ -20,4 +20,6 @@ typedef struct {
extern int git_socket_stream_new(git_stream **out, const char *host, const char *port); extern int git_socket_stream_new(git_stream **out, const char *host, const char *port);
extern int git_socket_stream_global_init(void);
#endif #endif
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "streams/mbedtls.h" #include "streams/mbedtls.h"
#include "streams/openssl.h" #include "streams/openssl.h"
#include "streams/stransport.h" #include "streams/stransport.h"
#include "streams/schannel.h"
int git_tls_stream_new(git_stream **out, const char *host, const char *port) int git_tls_stream_new(git_stream **out, const char *host, const char *port)
{ {
...@@ -33,6 +34,8 @@ int git_tls_stream_new(git_stream **out, const char *host, const char *port) ...@@ -33,6 +34,8 @@ int git_tls_stream_new(git_stream **out, const char *host, const char *port)
init = git_openssl_stream_new; init = git_openssl_stream_new;
#elif defined(GIT_MBEDTLS) #elif defined(GIT_MBEDTLS)
init = git_mbedtls_stream_new; init = git_mbedtls_stream_new;
#elif defined(GIT_SCHANNEL)
init = git_schannel_stream_new;
#endif #endif
} else { } else {
return error; return error;
...@@ -63,6 +66,8 @@ int git_tls_stream_wrap(git_stream **out, git_stream *in, const char *host) ...@@ -63,6 +66,8 @@ int git_tls_stream_wrap(git_stream **out, git_stream *in, const char *host)
wrap = git_openssl_stream_wrap; wrap = git_openssl_stream_wrap;
#elif defined(GIT_MBEDTLS) #elif defined(GIT_MBEDTLS)
wrap = git_mbedtls_stream_wrap; wrap = git_mbedtls_stream_wrap;
#elif defined(GIT_SCHANNEL)
wrap = git_schannel_stream_wrap;
#endif #endif
} }
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#cmakedefine GIT_OPENSSL_DYNAMIC 1 #cmakedefine GIT_OPENSSL_DYNAMIC 1
#cmakedefine GIT_SECURE_TRANSPORT 1 #cmakedefine GIT_SECURE_TRANSPORT 1
#cmakedefine GIT_MBEDTLS 1 #cmakedefine GIT_MBEDTLS 1
#cmakedefine GIT_SCHANNEL 1
#cmakedefine GIT_SHA1_COLLISIONDETECT 1 #cmakedefine GIT_SHA1_COLLISIONDETECT 1
#cmakedefine GIT_SHA1_WIN32 1 #cmakedefine GIT_SHA1_WIN32 1
......
...@@ -580,6 +580,17 @@ static int succeed_certificate_check(git_cert *cert, int valid, const char *host ...@@ -580,6 +580,17 @@ static int succeed_certificate_check(git_cert *cert, int valid, const char *host
return 0; return 0;
} }
static int x509_succeed_certificate_check(git_cert *cert, int valid, const char *host, void *payload)
{
GIT_UNUSED(valid);
GIT_UNUSED(payload);
cl_assert_equal_s("github.com", host);
cl_assert_equal_i(GIT_CERT_X509, cert->cert_type);
return 0;
}
static int fail_certificate_check(git_cert *cert, int valid, const char *host, void *payload) static int fail_certificate_check(git_cert *cert, int valid, const char *host, void *payload)
{ {
GIT_UNUSED(cert); GIT_UNUSED(cert);
...@@ -901,7 +912,7 @@ void test_online_clone__certificate_invalid(void) ...@@ -901,7 +912,7 @@ void test_online_clone__certificate_invalid(void)
void test_online_clone__certificate_valid(void) void test_online_clone__certificate_valid(void)
{ {
g_options.fetch_opts.callbacks.certificate_check = succeed_certificate_check; g_options.fetch_opts.callbacks.certificate_check = x509_succeed_certificate_check;
cl_git_pass(git_clone(&g_repo, "https://github.com/libgit2/TestGitRepository", "./foo", &g_options)); cl_git_pass(git_clone(&g_repo, "https://github.com/libgit2/TestGitRepository", "./foo", &g_options));
} }
......
...@@ -81,10 +81,10 @@ void test_stream_registration__tls(void) ...@@ -81,10 +81,10 @@ void test_stream_registration__tls(void)
cl_git_pass(git_stream_register(GIT_STREAM_TLS, NULL)); cl_git_pass(git_stream_register(GIT_STREAM_TLS, NULL));
error = git_tls_stream_new(&stream, "localhost", "443"); error = git_tls_stream_new(&stream, "localhost", "443");
/* We don't have TLS support enabled, or we're on Windows, /* We don't have TLS support enabled, or we're on Windows
* which has no arbitrary TLS stream support. * with WinHTTP, which is not actually TLS stream support.
*/ */
#if defined(GIT_WIN32) || !defined(GIT_HTTPS) #if defined(GIT_WINHTTP) || !defined(GIT_HTTPS)
cl_git_fail_with(-1, error); cl_git_fail_with(-1, error);
#else #else
cl_git_pass(error); cl_git_pass(error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment