Commit Graph

122 Commits

Author SHA1 Message Date
Edward Thomson
e536b2c50c cmake: enforce USE_SHA1 and USE_SHA256 validity 2024-10-22 11:45:58 +01:00
Edward Thomson
d1d65787b4 cmake: enforce USE_HTTPS validity 2024-10-22 11:45:58 +01:00
Edward Thomson
2125e3c64d cmake: enforce USE_SSH validity
Validate the USE_SSH option fits into our valid options; don't
assume a default.
2024-10-22 11:13:43 +01:00
Edward Thomson
0c675b8c84 cmake: enforce USE_HTTP_PARSER validity
When `-DUSE_HTTP_PARSER=...` is specified, ensure that the specified
HTTP Parser is valid, do not fallback to builtin.

Restore `-DUSE_HTTP_PARSER=system` for backcompatibility.
2024-10-22 10:07:12 +01:00
Edward Thomson
3d268285f9 sha: support FIPS-compliant OpenSSL for SHA1 2024-10-10 00:01:16 +01:00
Marcin Dabrowski
7f7dfe71cc Add OpenSSL-FIPS CMake flag
Usage of the deprecated 'SHA256_*' OpenSSL API in a FIPS compliant
environment results in OpenSSL's assertion failure with the following
description:
"OpenSSL internal error, assertion failed: Low level API call to
 digest SHA256 forbidden in FIPS mode!"

This commit adds a possibility to use the OpenSSL's 'EVP_MD*' API instead
of the deprecated 'SHA256_*' API, by extending the optional CMake flag
'USE_SHA256' with the new option called 'OpenSSL-FIPS'.
The new option is used to choose a hashing backend used by libgit2 to
calculate SHA256 hashes, in a similar way that currently existing
options like 'OpenSSL', 'OpenSSL-Dynamic', 'mbedTLS' etc do.

'OpenSSL-FIPS' is a fully opt-in option which is purposely not
interfering with the existing options, because, after running some
benchmarks, it's been discovered that using the 'EVP_MD*' API causes
hashing to be a bit slower in comparison to using the deprecated
'SHA256_*' API.

Another change introduced in this commit is the enhancement of the
Nightly workflow (nightly.yml) which will cause libgit2 to be
automatically built with '-DUSE_SHA256="OpenSSL-FIPS"' CMake flag,
on Linux, macOS and Windows.
2024-10-09 14:53:44 +02:00
Edward Thomson
41f6f72910 iOS Updates
Some minor refactoring for iOS:

- Roll back clar changes; these should be a bit more measured, and occur
  in clar upstream.
- Move iOS to nightly builds
2024-09-26 16:59:53 +02:00
Kyle
871208e991 Fix iconv link issue 2024-09-05 13:53:14 +08:00
Kyle
841164ec39 Fix regcomp_l compile issue 2024-09-05 00:07:31 +08:00
Kyle
4b63eb5dc8 Fix iOS build issue 2024-09-05 00:07:30 +08:00
Edward Thomson
fb1797de63 Merge remote-tracking branch 'origin/main' into libgit2-httpparser 2024-04-23 00:09:50 +01:00
Edward Thomson
d02b549dab http: make llhttp the default 2024-04-22 22:21:23 +01:00
Edward Thomson
d396819101 http: abstract http parsing out of httpclient
Avoid #ifdef's in httpclient.c, and move http parsing into its own file.
2024-04-22 22:21:23 +01:00
Edward Thomson
bfe0ac7632 Merge pull request #6631 from chris-forks/add-dl
add dl to LIBGIT2_SYSTEM_LIBS
2024-02-17 14:27:39 +00:00
Edward Thomson
e696528aa8 Update cmake/SelectHTTPSBackend.cmake 2024-02-17 14:27:19 +00:00
Stephen Gallagher
06e384a0a4 Enable llhttp for HTTP parsing
Fixes: https://github.com/libgit2/libgit2/issues/6074

We now try to use llhttp by default, falling back to http-parser
if the former is not available.

As a last resort, we use the bundled http-parser.

Co-authored-by: Sergio Correia <scorreia@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Sergio Correia <scorreia@redhat.com>
2024-02-07 17:01:59 -05:00
Edward Thomson
9d767b9d5e cmake: rename FindIconv to avoid collision with cmake
cmake now includes `FindIconv`. Rename ours to avoid any confusion.
2023-12-14 22:26:05 +00:00
Christopher Fujino
8dd5d60e80 guard 2023-09-09 20:50:42 -07:00
Christopher Fujino
40556c798a add dl to LIBGIT2_SYSTEM_LIBS 2023-09-09 20:06:12 -07:00
Edward Thomson
a8b052faab ssh: introduce GIT_SSH_EXEC for external OpenSSH
We can now use the `git_process` class to invoke OpenSSH and use it as
an SSH transport. This may be preferred over libssh2 for a variety of
callers.
2023-08-30 20:46:22 +01:00
Edward Thomson
3fccf7468b ssh: GIT_SSH_LIBSSH2 is now distinct from GIT_SSH
We may want to support SSH but with a different provider that is not
libssh2. Add GIT_SSH to indicate that we have some inbuilt SSH support
and GIT_SSH_LIBSSH2 to indicate that support is via libssh2. This is
similar to how we support GIT_HTTPS and GIT_OPENSSL, for example.
2023-08-30 20:46:21 +01:00
Christoph Reiter
86872834c5 cmake: fix openssl build on win32
since f15c8ac71a libgit unconditionally depends on secur32 on Windows
but only added it in cmake for the winhttp and schannel variants.
In case libgit is built against openssl it would fail to link.

This moves secur32 out of the https backend selection code into
the global win32 condition (and while at it also adds ws2_32 to the .pc file)
2023-08-19 10:44:25 +02:00
Edward Thomson
52db5d11c5 Revert "CMake: Search for ssh2 instead of libssh2." 2023-08-10 09:52:04 +01:00
Fabio Alessandrelli
933c09dbec CMake: Search for ssh2 instead of libssh2.
Fixes "CMake Error: could not resolve ssh2" on Windows-MSVC.
2023-06-25 07:15:02 +02:00
Edward Thomson
3335738579 cmake: refactor check_prototype_definition
Introduce `check_prototype_definition_safe` that is safe for `Werror`
usage.
2023-05-12 21:49:29 +01:00
Edward Thomson
abb0b31317 Merge pull request #6482 from libgit2/ethomson/xdiff
xdiff: move xdiff to 'deps'
2023-04-13 23:08:15 +01:00
Edward Thomson
f15c8ac71a http: add SSPI authentication on Windows
Add support for SSPI on Windows, which offers NTLM and Negotiate
authentication.
2023-03-21 09:15:14 +00:00
Edward Thomson
f68f542eb6 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).
2023-03-21 09:09:48 +00:00
Edward Thomson
462dbe21d0 xdiff: move xdiff to 'deps'
xdiff is a dependency (from git core) and more properly belongs in the
'deps' directory. Move it there, and add a stub for cmake to resolve
xdiff from the system location in the future. (At present, bundled xdiff
remains hardcoded.)
2023-03-03 09:45:12 +00:00
Edward Thomson
d63f1fe245 cmake: support older cmakes 2023-02-13 10:27:10 +00:00
Edward Thomson
c11724686c cmake: provide empty experimental.h for non-cmake users
Not everybody builds libgit2 using cmake; provide an `experimental.h`
with no experiments configured for those that do not. To support this,
we also now create compile definitions for experimental functionality,
to supplant that empty `experimental.h`. cmake will continue to generate
the proper `experimental.h` file for use with `make install`.
2022-09-19 06:34:51 -04:00
Edward Thomson
433a133402 Merge pull request #6191 from libgit2/ethomson/sha256_poc
RFC: SHA256 proof of concept
2022-07-13 21:08:04 -04:00
Jan Palus
636a275218 cmake: drop posix dependency from pcre* detection
since f585b12 neither PCRE nor PCRE2 backends rely on POSIX regex, so
reflect it in library detection logic
2022-07-07 10:50:08 +02:00
Edward Thomson
6c57bac6b1 sha256: make sha256 an experimental optional feature
libgit2 can be built with optional, experimental sha256 support. This
allows consumers to begin testing and providing feedback for our sha256
support while we continue to develop it, and allows us to make API
breaking changes while we iterate on a final sha256 implementation.

The results will be `git2-experimental.dll` and installed as
`git2-experimental.h` to avoid confusion with a production libgit2.
2022-06-20 17:12:49 -04:00
Edward Thomson
3bd9bb8d77 sha256: support dynamically loaded openssl 2022-04-04 13:29:19 -04:00
Edward Thomson
6a7d5d23c7 sha: support Win32 for SHA256
Adding SHA256 support prompted an overdue refactoring of some of the
unnecessary complexity around the CNG/CryptoAPI abstraction.
2022-03-23 08:39:19 -04:00
Edward Thomson
6b4a6faab3 sha: support OpenSSL for SHA256 2022-03-23 08:39:19 -04:00
Edward Thomson
b3e3fa10ea sha: support mbedTLS for SHA256 2022-03-23 08:39:19 -04:00
Edward Thomson
83c2778611 sha: support CommonCrypto for SHA256 2022-03-23 08:39:19 -04:00
Edward Thomson
b900981cf7 sha: add sha256 algorithm
Add support for a SHA256 hash algorithm, and add the "builtin" SHA256
hash engine (from RFC 6234).
2022-03-23 08:39:19 -04:00
Edward Thomson
8bc998f481 sha1: remove generic implementation
Remove the "generic" implementation; it should never be used; it only
existed for a no-dependencies configuration, and our bundled sha1dc
satisfies that requirement _and_ is correct.
2022-03-23 08:39:19 -04:00
Edward Thomson
d02f4f7ad7 cmake: refactor add_clar_test into separate module 2022-02-22 22:07:45 -05:00
Edward Thomson
c3b7ace9cf refactor: make util an object library
Instead of simply including the utility files directly, make them a
cmake object library for easy reusability between other projects within
libgit2.

Now the top-level `src` is responsible for platform selection, while the
next-level `libgit2` and `util` configurations are responsible for
identifying what objects they include.
2022-02-22 22:07:44 -05:00
Michał Górny
8bc9eda779 cmake: Fix package name for system http-parser
Fix building against system http-parser library by fixing
the find_package() argument.  It seems to have been accidentally changed
from HTTPParser to HTTP_Parser in de178d36f, effectively making
the build against system library fail to find it:

```
CMake Warning at cmake/SelectHTTPParser.cmake:3 (find_package):
  By not providing "FindHTTP_Parser.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "HTTP_Parser", but CMake did not find one.

  Could not find a package configuration file provided by "HTTP_Parser" with
  any of the following names:

    HTTP_ParserConfig.cmake
    http_parser-config.cmake

  Add the installation prefix of "HTTP_Parser" to CMAKE_PREFIX_PATH or set
  "HTTP_Parser_DIR" to a directory containing one of the above files.  If
  "HTTP_Parser" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  src/CMakeLists.txt:97 (include)

CMake Error at cmake/SelectHTTPParser.cmake:11 (message):
  http-parser support was requested but not found
Call Stack (most recent call first):
  src/CMakeLists.txt:97 (include)
```
2022-02-13 21:23:56 +01:00
Edward Thomson
46885ac9a4 Merge pull request #6153 from arroz/fix/apple-static-lib
Disabling setting `CMAKE_FIND_LIBRARY_SUFFIXES` on Apple platforms.
2022-01-30 21:20:29 -05:00
Miguel Arroz
be320340ed Introduced LINK_WITH_STATIC_LIBRARIES per PR comments. 2022-01-09 11:59:16 -08:00
Dimitris Apostolou
90df43022a Fix typos 2022-01-05 16:35:52 +02:00
Miguel Arroz
3eb3981978 Disabling setting CMAKE_FIND_LIBRARY_SUFFIXES on Apple platforms.
On macOS, since Big Sur, the libraries were moved to a cache. The SDK comes
with stubs in the SDK (`/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/lib/`
or whatever SDK version one has installed) where most have the `.tbd` suffix
(although some still are `.a`). Forcing `CMAKE_FIND_LIBRARY_SUFFIXES` on Apple
platforms broke building, unless one has copies of the libraries installed
elsewhere (like Brew), as many libraries (like `iconv` or `pcre`) are not
found.

This fix disables setting the `CMAKE_FIND_LIBRARY_SUFFIXES` to `.a` if
the platform is `APPLE` when building static libs.
2021-12-29 15:26:33 -08:00
Josh Junon
c5cd71b203 cmake: use PROJECT_SOURCE_DIR of CMAKE_SOURCE_DIR
Also applies to *_BINARY_DIR.

This effectively reverts 84083dcc8b,
which broke all users of libgit2 that use it as a CMake subdirectory
(via `add_subdirectory()`). This is because CMAKE_SOURCE_DIR refers
to the root-most CMake directory, which in the case of
`add_subdirectory()` is a parent project to libgit2 and thus the paths
don't make any sense to the configuration files. Corollary,
CMAKE_SOURCE_DIR only makes sense if the CMake project is always the
root project - which can rarely be guaranteed.

In all honesty, CMake should deprecate and eventually remove
CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR. It's been the source of headaches
and confusion for years, they're rarely useful over
CMAKE_CURRENT_(SOURCE|BINARY)_DIR or PROJECT_(SOURCE|BINARY)_DIR,
and they cause a lot of confusing configuration and source
code layouts to boot.

Any time they are used, they break `add_subdirectory()` almost 100% of
the time, cause confusing error messages, and hide subtle bugs.
2021-12-23 18:23:34 +01:00
Edward Thomson
84083dcc8b cmake: use CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR
Instead of using the project-specific `libgit2_SOURCE_DIR` and
`libgit2_BINARY_DIR` variables, use `CMAKE_SOURCE_DIR` and
`CMAKE_BINARY_DIR`.
2021-11-22 09:27:59 -05:00