aboutsummaryrefslogtreecommitdiffstats
path: root/docs/examples/simplessl.c
diff options
context:
space:
mode:
Diffstat (limited to 'docs/examples/simplessl.c')
-rw-r--r--docs/examples/simplessl.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/docs/examples/simplessl.c b/docs/examples/simplessl.c
index db3accaa..aefb79f6 100644
--- a/docs/examples/simplessl.c
+++ b/docs/examples/simplessl.c
@@ -1,18 +1,27 @@
-/*****************************************************************************
+/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- */
-
+ * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
#include <stdio.h>
#include <curl/curl.h>
-#include <curl/types.h>
-#include <curl/easy.h>
-
/* some requirements for this to work:
1. set pCertFile to the file with the client certificate
@@ -32,8 +41,9 @@
*/
-int main(int argc, char **argv)
+int main(void)
{
+ int i;
CURL *curl;
CURLcode res;
FILE *headerfile;
@@ -47,7 +57,7 @@ int main(int argc, char **argv)
const char *pEngine;
-#if USE_ENGINE
+#ifdef USE_ENGINE
pKeyName = "rsa_test";
pKeyType = "ENG";
pEngine = "chil"; /* for nChiper HSM... */
@@ -65,9 +75,9 @@ int main(int argc, char **argv)
if(curl) {
/* what call to write: */
curl_easy_setopt(curl, CURLOPT_URL, "HTTPS://your.favourite.ssl.site");
- curl_easy_setopt(curl, CURLOPT_WRITEHEADER, headerfile);
+ curl_easy_setopt(curl, CURLOPT_HEADERDATA, headerfile);
- while(1) /* do some ugly short cut... */
+ for(i = 0; i < 1; i++) /* single-iteration loop, just to break out from */
{
if (pEngine) /* use crypto engine */
{
@@ -109,8 +119,14 @@ int main(int argc, char **argv)
/* disconnect if we can't validate server's cert */
curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,1L);
+ /* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
- break; /* we are done... */
+ /* Check for errors */
+ if(res != CURLE_OK)
+ fprintf(stderr, "curl_easy_perform() failed: %s\n",
+ curl_easy_strerror(res));
+
+ /* we are done... */
}
/* always cleanup */
curl_easy_cleanup(curl);