Skip to content

Commit 84d83b8

Browse files
committed
http: do not try to use the cert callback on unencrypted streams
When the user has a certificate check callback set, we still have to check whether the stream we're using is even capable of providing a certificate. In the case of an unencrypted certificate, do not ask for it from the stream, and do not call the callback.
1 parent 29e7ae5 commit 84d83b8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-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

0 commit comments

Comments
 (0)