sslbackend.c
Go to the documentation of this file.
1 /***************************************************************************
2  * _ _ ____ _
3  * Project ___| | | | _ \| |
4  * / __| | | | |_) | |
5  * | (__| |_| | _ <| |___
6  * \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
9  *
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.
13  *
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.
17  *
18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19  * KIND, either express or implied.
20  *
21  ***************************************************************************/
22 /* <DESC>
23  * Shows HTTPS usage with client certs and optional ssl engine use.
24  * </DESC>
25  */
26 #include <assert.h>
27 #include <ctype.h>
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31 
32 #include <curl/curl.h>
33 
34 /*
35  * An SSL-enabled libcurl is required for this sample to work (at least one
36  * SSL backend has to be configured).
37  *
38  * **** This example only works with libcurl 7.56.0 and later! ****
39 */
40 
41 int main(int argc, char **argv)
42 {
43  const char *name = argc > 1 ? argv[1] : "openssl";
45 
46  if(!strcmp("list", name)) {
47  const curl_ssl_backend **list;
48  int i;
49 
50  result = curl_global_sslset(-1, NULL, &list);
51  assert(result == CURLSSLSET_UNKNOWN_BACKEND);
52 
53  for(i = 0; list[i]; i++)
54  printf("SSL backend #%d: '%s' (ID: %d)\n",
55  i, list[i]->name, list[i]->id);
56 
57  return 0;
58  }
59  else if(isdigit(*name)) {
60  curl_sslbackend id = (curl_sslbackend)atoi(name);
61 
62  result = curl_global_sslset(id, NULL, NULL);
63  }
64  else
65  result = curl_global_sslset(-1, name, NULL);
66 
67  if(result == CURLSSLSET_UNKNOWN_BACKEND) {
68  fprintf(stderr, "Unknown SSL backend id: %s\n", name);
69  return 1;
70  }
71 
72  assert(result == CURLSSLSET_OK);
73 
74  printf("Version with SSL backend '%s':\n\n\t%s\n", name, curl_version());
75 
76  return 0;
77 }
CURLsslset
Definition: curl.h:2371
UNITTEST_START int result
Definition: unit1304.c:49
unsigned int i
Definition: unit1303.c:79
curl_sslbackend
Definition: curl.h:137
#define printf
Definition: curl_printf.h:40
CURL_EXTERN CURLsslset curl_global_sslset(curl_sslbackend id, const char *name, const curl_ssl_backend ***avail)
Definition: vtls.c:1303
#define fprintf
Definition: curl_printf.h:41
int main(int argc, char **argv)
Definition: sslbackend.c:41
const char * name
Definition: curl_sasl.c:54
CURL_EXTERN char * curl_version(void)
Definition: version.c:77


rc_tagdetect_client
Author(s): Monika Florek-Jasinska , Raphael Schaller
autogenerated on Sat Feb 13 2021 03:42:16