Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 158d655

Browse files
committed
Update to LibGit2 v0.26.0
1 parent 2c85595 commit 158d655

File tree

14 files changed

+4521
-711
lines changed

14 files changed

+4521
-711
lines changed

base/libgit2/libgit2.jl

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -873,33 +873,13 @@ function set_ssl_cert_locations(cert_loc)
873873
cert_file = isfile(cert_loc) ? cert_loc : Cstring(C_NULL)
874874
cert_dir = isdir(cert_loc) ? cert_loc : Cstring(C_NULL)
875875
cert_file == C_NULL && cert_dir == C_NULL && return
876-
# TODO FIX https://github.com/libgit2/libgit2/pull/3935#issuecomment-253910017
877-
#ccall((:git_libgit2_opts, :libgit2), Cint,
878-
# (Cint, Cstring, Cstring),
879-
# Cint(Consts.SET_SSL_CERT_LOCATIONS), cert_file, cert_dir)
880-
ENV["SSL_CERT_FILE"] = cert_file
881-
ENV["SSL_CERT_DIR"] = cert_dir
876+
@check ccall((:git_libgit2_opts, :libgit2), Cint,
877+
(Cint, Cstring, Cstring),
878+
Cint(Consts.SET_SSL_CERT_LOCATIONS), cert_file, cert_dir)
882879
end
883880

884881
function __init__()
885-
# Look for OpenSSL env variable for CA bundle (linux only)
886-
# windows and macOS use the OS native security backends
887-
old_ssl_cert_dir = Base.get(ENV, "SSL_CERT_DIR", nothing)
888-
old_ssl_cert_file = Base.get(ENV, "SSL_CERT_FILE", nothing)
889-
@static if is_linux()
890-
cert_loc = if "SSL_CERT_DIR" in keys(ENV)
891-
ENV["SSL_CERT_DIR"]
892-
elseif "SSL_CERT_FILE" in keys(ENV)
893-
ENV["SSL_CERT_FILE"]
894-
else
895-
# If we have a bundled ca cert file, point libgit2 at that so SSL connections work.
896-
abspath(ccall(:jl_get_julia_home, Any, ()),Base.DATAROOTDIR,"julia","cert.pem")
897-
end
898-
set_ssl_cert_locations(cert_loc)
899-
end
900-
901-
err = ccall((:git_libgit2_init, :libgit2), Cint, ())
902-
err > 0 || throw(ErrorException("error initializing LibGit2 module"))
882+
@check ccall((:git_libgit2_init, :libgit2), Cint, ())
903883
REFCOUNT[] = 1
904884

905885
atexit() do
@@ -909,21 +889,18 @@ function __init__()
909889
end
910890
end
911891

892+
# Look for OpenSSL env variable for CA bundle (linux only)
893+
# windows and macOS use the OS native security backends
912894
@static if is_linux()
913-
if old_ssl_cert_dir != Base.get(ENV, "SSL_CERT_DIR", "")
914-
if old_ssl_cert_dir === nothing
915-
delete!(ENV, "SSL_CERT_DIR")
916-
else
917-
ENV["SSL_CERT_DIR"] = old_ssl_cert_dir
918-
end
919-
end
920-
if old_ssl_cert_file != Base.get(ENV, "SSL_CERT_FILE", "")
921-
if old_ssl_cert_file === nothing
922-
delete!(ENV, "SSL_CERT_FILE")
923-
else
924-
ENV["SSL_CERT_FILE"] = old_ssl_cert_file
925-
end
895+
cert_loc = if "SSL_CERT_DIR" in keys(ENV)
896+
ENV["SSL_CERT_DIR"]
897+
elseif "SSL_CERT_FILE" in keys(ENV)
898+
ENV["SSL_CERT_FILE"]
899+
else
900+
# If we have a bundled ca cert file, point libgit2 at that so SSL connections work.
901+
abspath(ccall(:jl_get_julia_home, Any, ()), Base.DATAROOTDIR, "julia", "cert.pem")
926902
end
903+
set_ssl_cert_locations(cert_loc)
927904
end
928905
end
929906

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0d6fd3ed9265c6804349149b23ae6362
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
88a8a42bb8d18a5a722938404e048266d0899362ac89fdfedfa9f71aeb90408d8d98b4d9b9ea2ff46755d0a2cd8686ff04d31e85827566e1290a9536b8b36ac8

deps/checksums/libgit2-2fcb8705e584ca61f6c4657525c9d2713f6a39d2.tar.gz/md5

Lines changed: 0 additions & 1 deletion
This file was deleted.

deps/checksums/libgit2-2fcb8705e584ca61f6c4657525c9d2713f6a39d2.tar.gz/sha512

Lines changed: 0 additions & 1 deletion
This file was deleted.

deps/libgit2.mk

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ LIBGIT2_OPTS += -DCURL_INCLUDE_DIRS=$(build_includedir) -DCURL_LIBRARIES="-L$(bu
3737
endif
3838

3939
ifeq ($(OS),Linux)
40-
LIBGIT2_OPTS += -DUSE_OPENSSL=OFF -DUSE_MBEDTLS=ON -DCMAKE_INSTALL_RPATH="\$$ORIGIN"
40+
LIBGIT2_OPTS += -DUSE_HTTPS=ON -DTLS_BACKEND="mbedTLS" -DCMAKE_INSTALL_RPATH="\$$ORIGIN"
4141
endif
4242
ifeq ($(OS),FreeBSD)
4343
LIBGIT2_OPTS += -DCMAKE_INSTALL_RPATH="\$$ORIGIN"
@@ -78,29 +78,14 @@ $(LIBGIT2_SRC_PATH)/libgit2-agent-nonfatal.patch-applied: $(LIBGIT2_SRC_PATH)/so
7878
patch -p1 -f < $(SRCDIR)/patches/libgit2-agent-nonfatal.patch
7979
echo 1 > $@
8080

81-
$(LIBGIT2_SRC_PATH)/libgit2-mbedtls-writer-fix.patch-applied: $(LIBGIT2_SRC_PATH)/source-extracted | $(LIBGIT2_SRC_PATH)/libgit2-mbedtls.patch-applied
82-
cd $(LIBGIT2_SRC_PATH) && \
83-
patch -p1 -f < $(SRCDIR)/patches/libgit2-mbedtls-writer-fix.patch
84-
echo 1 > $@
85-
86-
$(LIBGIT2_SRC_PATH)/libgit2-mbedtls-verify.patch-applied: $(LIBGIT2_SRC_PATH)/source-extracted | $(LIBGIT2_SRC_PATH)/libgit2-mbedtls-writer-fix.patch-applied
81+
$(LIBGIT2_SRC_PATH)/libgit2-mbedtls-verify.patch-applied: $(LIBGIT2_SRC_PATH)/source-extracted | $(LIBGIT2_SRC_PATH)/libgit2-agent-nonfatal.patch-applied
8782
cd $(LIBGIT2_SRC_PATH) && \
8883
patch -p1 -f < $(SRCDIR)/patches/libgit2-mbedtls-verify.patch
8984
echo 1 > $@
9085

91-
$(LIBGIT2_SRC_PATH)/libgit2-gitconfig-symlink.patch-applied: $(LIBGIT2_SRC_PATH)/source-extracted | $(LIBGIT2_SRC_PATH)/libgit2-mbedtls-verify.patch-applied
92-
cd $(LIBGIT2_SRC_PATH) && \
93-
patch -p1 -f < $(SRCDIR)/patches/libgit2-gitconfig-symlink.patch
94-
echo 1 > $@
95-
96-
$(LIBGIT2_SRC_PATH)/libgit2-free-config.patch-applied: $(LIBGIT2_SRC_PATH)/source-extracted | $(LIBGIT2_SRC_PATH)/libgit2-gitconfig-symlink.patch-applied
97-
cd $(LIBGIT2_SRC_PATH) && \
98-
patch -p1 -f < $(SRCDIR)/patches/libgit2-free-config.patch
99-
echo 1 > $@
100-
101-
$(LIBGIT2_SRC_PATH)/libgit2-remote-push-NULL.patch-applied: $(LIBGIT2_SRC_PATH)/source-extracted | $(LIBGIT2_SRC_PATH)/libgit2-free-config.patch-applied
86+
$(LIBGIT2_SRC_PATH)/libgit2-mbedtls-fixup.patch-applied: $(LIBGIT2_SRC_PATH)/source-extracted | $(LIBGIT2_SRC_PATH)/libgit2-mbedtls-verify.patch-applied
10287
cd $(LIBGIT2_SRC_PATH) && \
103-
patch -p1 -f < $(SRCDIR)/patches/libgit2-remote-push-NULL.patch
88+
patch -p1 -f < $(SRCDIR)/patches/libgit2-mbedtls-fixup.patch
10489
echo 1 > $@
10590

10691
$(build_datarootdir)/julia/cert.pem: $(CERTFILE)
@@ -111,11 +96,8 @@ $(BUILDDIR)/$(LIBGIT2_SRC_DIR)/build-configured: \
11196
$(LIBGIT2_SRC_PATH)/libgit2-mbedtls.patch-applied \
11297
$(LIBGIT2_SRC_PATH)/libgit2-ssh.patch-applied \
11398
$(LIBGIT2_SRC_PATH)/libgit2-agent-nonfatal.patch-applied \
114-
$(LIBGIT2_SRC_PATH)/libgit2-mbedtls-writer-fix.patch-applied \
11599
$(LIBGIT2_SRC_PATH)/libgit2-mbedtls-verify.patch-applied \
116-
$(LIBGIT2_SRC_PATH)/libgit2-gitconfig-symlink.patch-applied \
117-
$(LIBGIT2_SRC_PATH)/libgit2-free-config.patch-applied \
118-
$(LIBGIT2_SRC_PATH)/libgit2-remote-push-NULL.patch-applied
100+
$(LIBGIT2_SRC_PATH)/libgit2-mbedtls-fixup.patch-applied
119101

120102
ifneq ($(CERTFILE),)
121103
$(BUILDDIR)/$(LIBGIT2_SRC_DIR)/build-configured: $(build_datarootdir)/julia/cert.pem

deps/libgit2.version

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
LIBGIT2_BRANCH=v0.25.1
2-
LIBGIT2_SHA1=2fcb8705e584ca61f6c4657525c9d2713f6a39d2
1+
LIBGIT2_BRANCH=v0.26.0
2+
LIBGIT2_SHA1=15e119375018fba121cf58e02a9f17fe22df0df8

deps/patches/libgit2-gitconfig-symlink.patch

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
commit de8721ae70dfae529fdb50224a47eadf6d29c574
2+
Author: Curtis Vogt <[email protected]>
3+
Date: Thu Jun 29 16:31:08 2017 -0500
4+
5+
Corrections to mbedtls support with LibGit2 0.26.0
6+
7+
diff --git a/src/settings.c b/src/settings.c
8+
index 3a46f0d..4d976a0 100644
9+
--- a/src/settings.c
10+
+++ b/src/settings.c
11+
@@ -179,14 +179,18 @@ int git_libgit2_opts(int key, ...)
12+
const char *path = va_arg(ap, const char *);
13+
error = git_openssl_set_cert_file(file, path);
14+
}
15+
-#elif GIT_MBEDTLS
16+
+#elif defined(GIT_MBEDTLS)
17+
{
18+
const char *file = va_arg(ap, const char *);
19+
const char *path = va_arg(ap, const char *);
20+
- if (file)
21+
+ if (file) {
22+
error = git_mbedtls_set_cert_file(file, 0);
23+
- if (error && path)
24+
- error = git_mbedtls_set_cert_file(path, 0);
25+
+ } else if (path) {
26+
+ error = git_mbedtls_set_cert_file(path, 1);
27+
+ } else {
28+
+ giterr_set(GITERR_NET, "cannot set certificate locations: no file or path given");
29+
+ error = -1;
30+
+ }
31+
}
32+
#else
33+
giterr_set(GITERR_NET, "cannot set certificate locations: OpenSSL or mbedTLS is not enabled");
34+
diff --git a/src/streams/mbedtls.c b/src/streams/mbedtls.c
35+
index e456ea8..b4eb991 100644
36+
--- a/src/streams/mbedtls.c
37+
+++ b/src/streams/mbedtls.c
38+
@@ -205,12 +205,12 @@ static int ssl_set_error(mbedtls_ssl_context *ssl, int error)
39+
break;
40+
41+
case MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:
42+
- giterr_set(GITERR_SSL, "SSL error: %x[%x] - %s", error, ssl->session_negotiate->verify_result, errbuf);
43+
+ giterr_set(GITERR_SSL, "SSL error: 0x%04x [%x] - %s", error, ssl->session_negotiate->verify_result, errbuf);
44+
ret = GIT_ECERTIFICATE;
45+
break;
46+
47+
default:
48+
- giterr_set(GITERR_SSL, "SSL error: %x - %s", error, errbuf);
49+
+ giterr_set(GITERR_SSL, "SSL error: 0x%04x - %s", error, errbuf);
50+
}
51+
52+
return ret;
53+
@@ -236,7 +236,7 @@ static int verify_server_cert(mbedtls_ssl_context *ssl, const char *host)
54+
if ((ret = mbedtls_ssl_get_verify_result(ssl)) != 0) {
55+
char vrfy_buf[512];
56+
mbedtls_x509_crt_verify_info(vrfy_buf, sizeof(vrfy_buf), "", ret);
57+
- giterr_set(GITERR_SSL, "The SSL certificate is invalid: %x - %s", ret, vrfy_buf);
58+
+ giterr_set(GITERR_SSL, "The SSL certificate is invalid: 0x%04x - %s", ret, vrfy_buf);
59+
return GIT_ECERTIFICATE;
60+
}
61+
62+
@@ -430,7 +430,7 @@ int git_mbedtls_set_cert_file(const char *path, int is_dir)
63+
ret = mbedtls_x509_crt_parse_file(cacert, path);
64+
}
65+
// mbedtls_x509_crt_parse_path returns the number of invalid certs on success
66+
- if (ret <= 0) {
67+
+ if (ret < 0) {
68+
mbedtls_x509_crt_free(cacert);
69+
git__free(cacert);
70+
mbedtls_strerror( ret, errbuf, 512 );

0 commit comments

Comments
 (0)