Skip to content

Commit 828e595

Browse files
committed
Merge pull request libgit2#2982 from libgit2/cmn/stream-check-ec
Don't ask for a stream's certificate unless it's encrypted
2 parents c07d020 + 84d83b8 commit 828e595

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/stream.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ GIT_INLINE(int) git_stream_connect(git_stream *st)
1515
return st->connect(st);
1616
}
1717

18+
GIT_INLINE(int) git_stream_is_encrypted(git_stream *st)
19+
{
20+
return st->encrypted;
21+
}
22+
1823
GIT_INLINE(int) git_stream_certificate(git_cert **out, git_stream *st)
1924
{
2025
if (!st->encrypted) {

src/transports/http.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,8 @@ static int http_connect(http_subtransport *t)
558558
error = git_stream_connect(t->io);
559559

560560
#ifdef GIT_SSL
561-
if ((!error || error == GIT_ECERTIFICATE) && t->owner->certificate_check_cb != NULL) {
561+
if ((!error || error == GIT_ECERTIFICATE) && t->owner->certificate_check_cb != NULL &&
562+
git_stream_is_encrypted(t->io)) {
562563
git_cert *cert;
563564
int is_valid;
564565

tests/online/clone.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,3 +565,10 @@ void test_online_clone__certificate_valid(void)
565565

566566
cl_git_pass(git_clone(&g_repo, "https://github.com/libgit2/TestGitRepository", "./foo", &g_options));
567567
}
568+
569+
void test_online_clone__start_with_http(void)
570+
{
571+
g_options.remote_callbacks.certificate_check = succeed_certificate_check;
572+
573+
cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
574+
}

0 commit comments

Comments
 (0)