1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
23 * Shows HTTPS usage with client certs and optional ssl engine use.
32 #include <curl/curl.h>
35 * An SSL-enabled libcurl is required for this sample to work (at least one
36 * SSL backend has to be configured).
38 * **** This example only works with libcurl 7.56.0 and later! ****
41 int main(int argc, char **argv)
43 const char *name = argc > 1 ? argv[1] : "openssl";
46 if(!strcmp("list", name)) {
47 const curl_ssl_backend **list;
50 result = curl_global_sslset(-1, NULL, &list);
51 assert(result == CURLSSLSET_UNKNOWN_BACKEND);
53 for(i = 0; list[i]; i++)
54 printf("SSL backend #%d: '%s' (ID: %d)\n",
55 i, list[i]->name, list[i]->id);
59 else if(isdigit(*name)) {
60 curl_sslbackend id = (curl_sslbackend)atoi(name);
62 result = curl_global_sslset(id, NULL, NULL);
65 result = curl_global_sslset(-1, name, NULL);
67 if(result == CURLSSLSET_UNKNOWN_BACKEND) {
68 fprintf(stderr, "Unknown SSL backend id: %s\n", name);
72 assert(result == CURLSSLSET_OK);
74 printf("Version with SSL backend '%s':\n\n\t%s\n", name, curl_version());