在server.xml中增加下面的内容:

  1. ciphers="SSL_RSA_WITH_RC4_128_SHA"  

下面是libcurl 的测试代码:

  1. #include <stdio.h>  
  2. #include <stdlib.h>  
  3. #include <string.h>  
  4. #include <curl/curl.h>  
  5.   
  6. static size_t save_response_callback(void *buffer,size_t size,size_t count,void **response)  
  7. {  
  8.     char * ptr = NULL;  
  9.     printf("buffer is %s\n",(char *)buffer);  
  10.     ptr =(char *) malloc(count*size + 4);  
  11.     memcpy(ptr,buffer,count*size);  
  12.     *response = ptr;  
  13.   
  14.     return count;  
  15. }  
  16.   
  17. int main(int argc,char *argv[])  
  18. {  
  19.     CURL * curl;  
  20.     CURLcode res;  
  21.     char * response = NULL;  
  22.   
  23.     if(argc !=2){  
  24.         printf("Usage:file<url>;\n");  
  25.         return;  
  26.     }  
  27.       
  28.     //curl_global_init(CURL_GLOBAL_DEFAULT);  
  29.   
  30.     curl = curl_easy_init();  
  31.      
  32.     if(curl!=NULL){  
  33.         printf("Usage:file<%s>;\n",argv[1]);  
  34.         curl_easy_setopt(curl,CURLOPT_URL,argv[1]);  
  35.         curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,&save_response_callback);  
  36.         curl_easy_setopt(curl,CURLOPT_WRITEDATA,&response);  
  37.         curl_easy_setopt(curl,CURLOPT_COOKIESESSION,1L);  
  38.         curl_easy_setopt(curl,CURLOPT_COOKIEFILE,"/dev/null");  
  39.         curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,1);  
  40.         //curl_easy_setopt(curl,CURLOPT_CAPATH,"/etc/ssl/cert/");  
  41.         curl_easy_setopt(curl,CURLOPT_CAINFO,"ca-cert.pem");  
  42.   
  43.         curl_easy_setopt(curl,CURLOPT_SSL_VERIFYHOST,1);  
  44.         curl_easy_setopt(curl,CURLOPT_VERBOSE,1L);  
  45.         curl_easy_setopt(curl,CURLOPT_TIMEOUT,30);  
  46. #if 0  
  47.         /* 双向验证下面是客户端的CA*/  
  48.     //  curl_easy_setopt(curl,CURLOPT_CAPATH,"./");  
  49.         curl_easy_setopt(curl,CURLOPT_SSLCERT,"client-cert.pem");  
  50.         curl_easy_setopt(curl,CURLOPT_SSLCERTPASSWD,"password");  
  51.         curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM");  
  52.         curl_easy_setopt(curl,CURLOPT_SSLKEY,"client-key.pem");  
  53.         curl_easy_setopt(curl,CURLOPT_SSLKEYPASSWD,"password");  
  54.         curl_easy_setopt(curl,CURLOPT_SSLKEYTYPE,"PEM");  
  55. #endif  
  56.   
  57.         res = curl_easy_perform(curl);  
  58.         if(res != CURLE_OK){  
  59.   
  60.              printf("curl_wasy_perform error = %s",curl_easy_strerror(res));  
  61.         }  
  62.         printf("response<%s>\n",response);  
  63.   
  64.         curl_easy_cleanup(curl);  
  65.     }  
  66.   
  67.   
  68. }  
参考资料:
SSL证书制作:http://blog.chinaunix.net/uid-7591044-id-1742977.html 
posted on 2014-04-04 17:36  未雨愁眸  阅读(1638)  评论(0编辑  收藏  举报