summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/transports/http.c4
-rw-r--r--src/transports/smart.c10
-rw-r--r--src/transports/ssh.c9
-rw-r--r--src/transports/winhttp.c5
4 files changed, 23 insertions, 5 deletions
diff --git a/src/transports/http.c b/src/transports/http.c
index 51219963c..7f9d35012 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -371,6 +371,7 @@ static int on_headers_complete(http_parser *parser)
allowed_auth_types,
t->owner->cred_acquire_payload);
+ /* treat GIT_PASSTHROUGH as if callback isn't set */
if (error == GIT_PASSTHROUGH) {
no_callback = 1;
} else if (error < 0) {
@@ -639,6 +640,9 @@ static int http_connect(http_subtransport *t)
giterr_clear();
error = t->owner->certificate_check_cb(cert, is_valid, t->connection_data.host, t->owner->message_cb_payload);
+ if (error == GIT_PASSTHROUGH)
+ error = is_valid ? 0 : GIT_ECERTIFICATE;
+
if (error < 0) {
if (!giterr_last())
giterr_set(GITERR_NET, "user cancelled certificate check");
diff --git a/src/transports/smart.c b/src/transports/smart.c
index e972d30ba..9fcbdcf21 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -481,6 +481,11 @@ int git_transport_smart_certificate_check(git_transport *transport, git_cert *ce
{
transport_smart *t = (transport_smart *)transport;
+ assert(transport && cert && hostname);
+
+ if (!t->certificate_check_cb)
+ return GIT_PASSTHROUGH;
+
return t->certificate_check_cb(cert, valid, hostname, t->message_cb_payload);
}
@@ -488,6 +493,11 @@ int git_transport_smart_credentials(git_cred **out, git_transport *transport, co
{
transport_smart *t = (transport_smart *)transport;
+ assert(out && transport);
+
+ if (!t->cred_acquire_cb)
+ return GIT_PASSTHROUGH;
+
return t->cred_acquire_cb(out, t->url, user, methods, t->cred_acquire_payload);
}
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index 7d9114c26..9e01a4aea 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -447,11 +447,11 @@ static int request_creds(git_cred **out, ssh_subtransport *t, const char *user,
error = t->owner->cred_acquire_cb(&cred, t->owner->url, user, auth_methods,
t->owner->cred_acquire_payload);
- if (error == GIT_PASSTHROUGH)
+ if (error == GIT_PASSTHROUGH) {
no_callback = 1;
- else if (error < 0)
+ } else if (error < 0) {
return error;
- else if (!cred) {
+ } else if (!cred) {
giterr_set(GITERR_SSH, "callback failed to initialize SSH credentials");
return -1;
}
@@ -584,7 +584,8 @@ post_extract:
cert_ptr = &cert;
error = t->owner->certificate_check_cb((git_cert *) cert_ptr, 0, host, t->owner->message_cb_payload);
- if (error < 0) {
+
+ if (error < 0 && error != GIT_PASSTHROUGH) {
if (!giterr_last())
giterr_set(GITERR_NET, "user cancelled hostkey check");
diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c
index e925dbdc0..5e7bde73c 100644
--- a/src/transports/winhttp.c
+++ b/src/transports/winhttp.c
@@ -228,7 +228,7 @@ static int fallback_cred_acquire_cb(
}
hCoInitResult = CoInitializeEx(NULL, COINIT_MULTITHREADED);
-
+
if (SUCCEEDED(hCoInitResult) || hCoInitResult == RPC_E_CHANGED_MODE) {
IInternetSecurityManager* pISM;
@@ -295,6 +295,9 @@ static int certificate_check(winhttp_stream *s, int valid)
error = t->owner->certificate_check_cb((git_cert *) &cert, valid, t->connection_data.host, t->owner->message_cb_payload);
CertFreeCertificateContext(cert_ctx);
+ if (error == GIT_PASSTHROUGH)
+ error = valid ? 0 : GIT_ECERTIFICATE;
+
if (error < 0 && !giterr_last())
giterr_set(GITERR_NET, "user cancelled certificate check");