git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] http.c: prompt for SSL client certificate password

From
Mark Lodato <lodatom@gmail.com>
Date
Jun 12, 2009, 23:13 UTC
Message-ID
<ca433830906121613y68e5bdax5778867c41b00339@mail.gmail.com>
In-Reply-To
<7vprdaarka.fsf@alter.siamese.dyndns.org>
On Fri, Jun 12, 2009 at 2:34 AM, Junio C Hamano<gitster@pobox.com> wrote:
Show 35 quoted lines
> Mark Lodato <lodatom@gmail.com> writes:
>
>> @@ -189,6 +207,16 @@ static CURL *get_curl_handle(void)
>>
>>       if (ssl_cert != NULL)
>>               curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert);
>> +     if (has_cert_password())
>> +             curl_easy_setopt(result,
>> +#if LIBCURL_VERSION_NUM >= 0x071700
>> +                              CURLOPT_KEYPASSWD,
>> +#elif LIBCURL_VERSION_NUM >= 0x070903
>> +                              CURLOPT_SSLKEYPASSWD,
>> +#else
>> +                              CURLOPT_SSLCERTPASSWD,
>> +#endif
>> +                              ssl_cert_password);
>
> This is purely style and readability, but if you do something like this
> much earlier in the file:
>
>    #if !defined(CURLOPT_KEYPASSWD)
>    # if defined(CURLOPT_SSLKEYPASSWD)
>    #  define CURLOPT_KEYTPASSWD CURLOPT_SSLKEYPASSWD
>    # elif defined(CURLOPT_SSLCERTPASSWD
>    #  define CURLOPT_KEYTPASSWD CURLOPT_SSLCERTPASSWD
>    # endif
>    #endif
>
> you can write your main codepath using the latest cURL API without ifdef.
> The callsite can simply say:
>
>        if (must_set_cert_password())
>                curl_easy_setopt(result, CURLOPT_KEYPASSWD, ssl_cert_password);
>
> which I think would be much easier to follow.

I realized this after I submitted the patch. Locally I have modified my version to do something similar to the above, but checking libcurl versions rather than checking the existence of the macros (which don't exist, as Daniel pointed out.) If this patch series is accepted, I will make a cleaner version that includes this change.

Mark
Previous: Daniel StenbergNext: Junio C Hamano
Message 22 of 25 in “http.c: prompt for SSL client certificate password”
  1. 1/2 http.c: prompt for SSL client certificate passwordMark Lodato, May 28, 2009
  2. 2/2 http.c: add http.sslCertNoPass optionMark Lodato, May 28, 2009
  3. Mark LodatoJun 5, 2009
  4. Constantine PlotnikovJun 5, 2009
  5. Mark LodatoJun 7, 2009
  6. Mark LodatoJun 11, 2009
  7. Nanako ShiraishiJun 11, 2009
  8. Junio C HamanoJun 11, 2009
  9. Daniel StenbergJun 12, 2009
  10. Constantine PlotnikovJun 12, 2009
  11. Jakub NarebskiJun 12, 2009
  12. Rogan DawesJun 12, 2009
  13. Mark LodatoJun 12, 2009
  14. Mark LodatoJun 12, 2009
  15. Junio C HamanoJun 13, 2009
  16. Mark LodatoJun 13, 2009
  17. Daniel StenbergJun 13, 2009
  18. Junio C HamanoJun 11, 2009
  19. Mark LodatoJun 12, 2009
  20. Junio C HamanoJun 12, 2009
  21. Daniel StenbergJun 12, 2009
  22. Mark LodatoJun 12, 2009
  23. Junio C HamanoJun 13, 2009
  24. Mark LodatoJun 13, 2009
  25. Junio C HamanoJun 13, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.