Merge branch 'mh/maint-honor-no-ssl-verify'
authorJunio C Hamano <gitster@pobox.com>
Tue, 16 Sep 2008 07:46:36 +0000 (00:46 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Sep 2008 07:46:36 +0000 (00:46 -0700)
* mh/maint-honor-no-ssl-verify:
Don't verify host name in SSL certs when GIT_SSL_NO_VERIFY is set

1  2 
http.c
diff --combined http.c
index 07889367040c4b49ca335262a69cfd91ba637f3c,a97fdf51173cf73d883c024d85109cbd4e607db9..ed59b79709b11dc6f6d85e86d75a1a8883799f21
--- 1/http.c
--- 2/http.c
+++ b/http.c
@@@ -165,7 -165,16 +165,16 @@@ static CURL* get_curl_handle(void
  {
        CURL* result = curl_easy_init();
  
-       curl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, curl_ssl_verify);
+       if (!curl_ssl_verify) {
+               curl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0);
+               curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 0);
+       } else {
+               /* Verify authenticity of the peer's certificate */
+               curl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 1);
+               /* The name in the cert must match whom we tried to connect */
+               curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);
+       }
  #if LIBCURL_VERSION_NUM >= 0x070907
        curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
  #endif
@@@ -402,7 -411,7 +411,7 @@@ static struct fill_chain *fill_cfg = NU
  
  void add_fill_function(void *data, int (*fill)(void *))
  {
 -      struct fill_chain *new = malloc(sizeof(*new));
 +      struct fill_chain *new = xmalloc(sizeof(*new));
        struct fill_chain **linkp = &fill_cfg;
        new->data = data;
        new->fill = fill;