https.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*****************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * $Id$
  9. */
  10. #include <stdio.h>
  11. #include <curl/curl.h>
  12. int main(void)
  13. {
  14. CURL *curl;
  15. CURLcode res;
  16. curl = curl_easy_init();
  17. if(curl) {
  18. curl_easy_setopt(curl, CURLOPT_URL, "https://sourceforge.net/");
  19. #ifdef SKIP_PEER_VERIFICATION
  20. /*
  21. * If you want to connect to a site who isn't using a certificate that is
  22. * signed by one of the certs in the CA bundle you have, you can skip the
  23. * verification of the server's certificate. This makes the connection
  24. * A LOT LESS SECURE.
  25. *
  26. * If you have a CA cert for the server stored someplace else than in the
  27. * default bundle, then the CURLOPT_CAPATH option might come handy for
  28. * you.
  29. */
  30. curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
  31. #endif
  32. #ifdef SKIP_HOSTNAME_VERFICATION
  33. /*
  34. * If the site you're connecting to uses a different host name that what
  35. * they have mentioned in their server certificate's commonName (or
  36. * subjectAltName) fields, libcurl will refuse to connect. You can skip
  37. * this check, but this will make the connection less secure.
  38. */
  39. curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
  40. #endif
  41. res = curl_easy_perform(curl);
  42. /* always cleanup */
  43. curl_easy_cleanup(curl);
  44. }
  45. return 0;
  46. }