disabled ssl cert verification

Sat, 01 Dec 2012 16:31:36 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 01 Dec 2012 16:31:36 +0100
changeset 3
323689ada09d
parent 2
f7e408d98a83
child 4
ae5a98f0545c

disabled ssl cert verification

dav/main.c file | annotate | diff | comparison | revisions
dav/propfind.c file | annotate | diff | comparison | revisions
dav/utils.c file | annotate | diff | comparison | revisions
--- a/dav/main.c	Sat Dec 01 14:49:34 2012 +0100
+++ b/dav/main.c	Sat Dec 01 16:31:36 2012 +0100
@@ -115,6 +115,7 @@
 
 void get_file(CURL *curl, char *url, char *path) {
     curl_easy_setopt(curl, CURLOPT_URL, url);
+    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
     
     FILE *out = fopen(path, "w");
     
@@ -124,4 +125,32 @@
     CURLcode res = curl_easy_perform(curl);
     
     fclose(out);
+    // handle some errors (http://curl.haxx.se/libcurl/c/libcurl-errors.html)
+    switch(res) {
+        case CURLE_OK: {
+            return;
+        }
+        case CURLE_REMOTE_ACCESS_DENIED: {
+            
+            break;
+        }
+        case CURLE_SSL_CONNECT_ERROR: {
+            
+            break;
+        }
+        case CURLE_LOGIN_DENIED: {
+            
+            break;
+        }
+        case CURLE_REMOTE_FILE_NOT_FOUND: {
+            
+            break;
+        }
+        default: {
+            
+            break;
+        }
+    }
+    
+    unlink(path);
 }
--- a/dav/propfind.c	Sat Dec 01 14:49:34 2012 +0100
+++ b/dav/propfind.c	Sat Dec 01 16:31:36 2012 +0100
@@ -42,12 +42,15 @@
     
     struct curl_slist *headers = NULL;
     headers = curl_slist_append(headers, "Content-Type: text/xml");
+    headers = curl_slist_append(headers, "Depth: 1");
     curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
     
     UcxBuffer *rqbuf = create_propfind_request_body();
     UcxBuffer *rpbuf = ucx_buffer_new(NULL, 4096, UCX_BUFFER_AUTOEXTEND);
     //printf("request\n%s\n", body->space);
     
+    curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0);
+    
     curl_easy_setopt(handle, CURLOPT_UPLOAD, 1); 
     curl_easy_setopt(handle, CURLOPT_READFUNCTION, ucx_buffer_read);
     curl_easy_setopt(handle, CURLOPT_READDATA, rqbuf); 
@@ -59,7 +62,7 @@
     ucx_buffer_seek(rqbuf, 0, SEEK_SET);
     CURLcode res = curl_easy_perform(handle);
     if(res == CURLE_OK) {
-        //printf("response\n%s\n", rpbuf->space);
+        printf("response\n%s\n", rpbuf->space);
         
         char *url = NULL;
         curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url);
--- a/dav/utils.c	Sat Dec 01 14:49:34 2012 +0100
+++ b/dav/utils.c	Sat Dec 01 16:31:36 2012 +0100
@@ -36,11 +36,15 @@
 
 
 time_t parse_creationdate(char *str) {
+    // example: 2012-11-29T21:35:35Z
+    
     // TODO
     return 1234;
 }
 
 time_t parse_lastmodified(char *str) {
+    // example: Thu, 29 Nov 2012 21:35:35 GMT
+    
     // TODO
     return 1234;
 }
@@ -80,7 +84,7 @@
     char *name = url + si + 1;;
     if(name[0] == 0) {
         name = url + osi + 1;
-        if(name[0 == 0]) {
+        if(name[0] == 0) {
             return url;
         }
     }

mercurial