10000 Add -DUSE_CURL_SSL to allow distros to avoid OpenSSL by infinity0 · Pull Request #4325 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

Add -DUSE_CURL_SSL to allow distros to avoid OpenSSL #4325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Revert "curl: remove the encrypted param to the constructor"
This reverts commit 8443f49.
  • Loading branch information
infinity0 committed Aug 1, 2017
commit e96800420abf894673e8eeca4af5277dbb12d730
14 changes: 11 additions & 3 deletions src/curl_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ static void curls_free(git_stream *stream)
git__free(s);
}

int git_curl_stream_new(git_stream **out, const char *host, const char *port)
int git_curl_stream_new(git_stream **out, const char *host, const char *port, int encrypted)
{
curl_stream *st;
CURL *handle;
Expand All @@ -317,7 +317,15 @@ int git_curl_stream_new(git_stream **out, const char *host, const char *port)
return error;
}

curl_easy_setopt(handle, CURLOPT_URL, host);
if (encrypted) {
git_buf buf = GIT_BUF_INIT;
git_buf_printf(&buf, "https://%s", host);
curl_easy_setopt(handle, CURLOPT_URL, buf.ptr);
git_buf_free(&buf);
} else {
curl_easy_setopt(handle, CURLOPT_URL, host);
}

curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, st->curl_error);
curl_easy_setopt(handle, CURLOPT_PORT, iport);
curl_easy_setopt(handle, CURLOPT_CONNECT_ONLY, 1);
Expand All @@ -329,7 +337,7 @@ int git_curl_stream_new(git_stream **out, const char *host, const char *port)
/* curl_easy_setopt(handle, CURLOPT_VERBOSE, 1); */

st->parent.version = GIT_STREAM_VERSION;
st->parent.encrypted = 0; /* we don't encrypt ourselves */
st->parent.encrypted = encrypted;
st->parent.proxy_support = 1;
st->parent.connect = curls_connect;
st->parent.certificate = curls_certificate;
Expand Down
2 changes: 1 addition & 1 deletion src/curl_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

#include "git2/sys/stream.h"

extern int git_curl_stream_new(git_stream **out, const char *host, const char *port);
extern int git_curl_stream_new(git_stream **out, const char *host, const char *port, bool encrypted);

#endif
2 changes: 1 addition & 1 deletion src/openssl_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ int git_openssl_stream_new(git_stream **out, const char *host, const char *port)

st->io = NULL;
#ifdef GIT_CURL
error = git_curl_stream_new(&st->io, host, port);
error = git_curl_stream_new(&st->io, host, port, false);
#else
error = git_socket_stream_new(&st->io, host, port);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/transports/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ static int http_connect(http_subtransport *t)
error = git_tls_stream_new(&t->io, t->connection_data.host, t->connection_data.port);
} else {
#ifdef GIT_CURL
error = git_curl_stream_new(&t->io, t->connection_data.host, t->connection_data.port);
error = git_curl_stream_new(&t->io, t->connection_data.host, t->connection_data.port, false);
#else
error = git_socket_stream_new(&t->io, t->connection_data.host, t->connection_data.port);
#endif
Expand Down
0