Subject: [PATCH 1/3] Support for SSL client cert

From: Nick Hengeveld <[email-masked]>
Date: Mon, 26 Sep 2005 10:51:57 -0700

Added SSL client args and CURL settings

Signed-off-by: Nick Hengeveld <[email-masked]>

---

 http-fetch.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

2d293c34fdfde8a394b5f8a5c5343d9caf363bcc
diff --git a/http-fetch.c b/http-fetch.c
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -476,6 +476,10 @@ int main(int argc, char **argv)
 	char *commit_id;
 	char *url;
 	int arg = 1;
+	char *ssl_cert = NULL;
+	char *ssl_key = NULL;
+	char *ssl_capath = NULL;
+	char *ssl_cacert = NULL;
 
 	while (arg < argc && argv[arg][0] == '-') {
 		if (argv[arg][1] == 't') {
@@ -491,11 +495,19 @@ int main(int argc, char **argv)
 		} else if (argv[arg][1] == 'w') {
 			write_ref = argv[arg + 1];
 			arg++;
+		} else if (arg+1 < argc && !strcmp(argv[arg], "--cert")) {
+			ssl_cert = argv[++arg];
+		} else if (arg+1 < argc && !strcmp(argv[arg], "--key")) {
+			ssl_key = argv[++arg];
+		} else if (arg+1 < argc && !strcmp(argv[arg], "--capath")) {
+			ssl_capath = argv[++arg];
+		} else if (arg+1 < argc && !strcmp(argv[arg], "--cacert")) {
+			ssl_cacert = argv[++arg];
 		}
 		arg++;
 	}
 	if (argc < arg + 2) {
-		usage("git-http-fetch [-c] [-t] [-a] [-d] [-v] [--recover] [-w ref] commit-id url");
+		usage("git-http-fetch [-c] [-t] [-a] [-d] [-v] [--recover] [-w ref] [--cert ssl-cert-file] [--key ssl-key-file] [--capath CA-dir] [--cacert CA-cert-file] commit-id url");
 		return 1;
 	}
 	commit_id = argv[arg];
@@ -506,6 +518,20 @@ int main(int argc, char **argv)
 	curl = curl_easy_init();
 	no_pragma_header = curl_slist_append(no_pragma_header, "Pragma:");
 
+        /* Set SSL parameters if they were provided */
+	if (ssl_cert != NULL) {
+		curl_easy_setopt(curl, CURLOPT_SSLCERT, ssl_cert);
+	}
+	if (ssl_key != NULL) {
+		curl_easy_setopt(curl, CURLOPT_SSLKEY, ssl_key);
+	}
+	if (ssl_capath != NULL) {
+		curl_easy_setopt(curl, CURLOPT_CAPATH, ssl_capath);
+	}
+	if (ssl_cacert != NULL) {
+		curl_easy_setopt(curl, CURLOPT_CAINFO, ssl_cacert);
+	}
+
 	curl_ssl_verify = getenv("GIT_SSL_NO_VERIFY") ? 0 : 1;
 	curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, curl_ssl_verify);
 #if LIBCURL_VERSION_NUM >= 0x070907