libcurl使用认证证书 https认证
来源:互联网 发布:网络兼职英语教师招聘 编辑:程序博客网 时间:2024/05/18 09:37
在server.xml中增加下面的内容:
- ciphers="SSL_RSA_WITH_RC4_128_SHA"
下面是libcurl 的测试代码:
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <curl/curl.h>
- static size_t save_response_callback(void *buffer,size_t size,size_t count,void **response)
- {
- char * ptr = NULL;
- printf("buffer is %s\n",(char *)buffer);
- ptr =(char *) malloc(count*size + 4);
- memcpy(ptr,buffer,count*size);
- *response = ptr;
- return count;
- }
- int main(int argc,char *argv[])
- {
- CURL * curl;
- CURLcode res;
- char * response = NULL;
- if(argc !=2){
- printf("Usage:file<url>;\n");
- return;
- }
- //curl_global_init(CURL_GLOBAL_DEFAULT);
- curl = curl_easy_init();
- if(curl!=NULL){
- printf("Usage:file<%s>;\n",argv[1]);
- curl_easy_setopt(curl,CURLOPT_URL,argv[1]);
- curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,&save_response_callback);
- curl_easy_setopt(curl,CURLOPT_WRITEDATA,&response);
- curl_easy_setopt(curl,CURLOPT_COOKIESESSION,1L);
- curl_easy_setopt(curl,CURLOPT_COOKIEFILE,"/dev/null");
- curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,1);
- //curl_easy_setopt(curl,CURLOPT_CAPATH,"/etc/ssl/cert/");
- curl_easy_setopt(curl,CURLOPT_CAINFO,"ca-cert.pem");
- curl_easy_setopt(curl,CURLOPT_SSL_VERIFYHOST,1);
- curl_easy_setopt(curl,CURLOPT_VERBOSE,1L);
- curl_easy_setopt(curl,CURLOPT_TIMEOUT,30);
- #if 0
- /* 双向验证下面是客户端的CA*/
- // curl_easy_setopt(curl,CURLOPT_CAPATH,"./");
- curl_easy_setopt(curl,CURLOPT_SSLCERT,"client-cert.pem");
- curl_easy_setopt(curl,CURLOPT_SSLCERTPASSWD,"password");
- curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM");
- curl_easy_setopt(curl,CURLOPT_SSLKEY,"client-key.pem");
- curl_easy_setopt(curl,CURLOPT_SSLKEYPASSWD,"password");
- curl_easy_setopt(curl,CURLOPT_SSLKEYTYPE,"PEM");
- #endif
- res = curl_easy_perform(curl);
- if(res != CURLE_OK){
- printf("curl_wasy_perform error = %s",curl_easy_strerror(res));
- }
- printf("response<%s>\n",response);
- curl_easy_cleanup(curl);
- }
- }
源码测试用例:http://curl.haxx.se/libcurl/c/https.html
教程:http://blog.csdn.net/jgood/article/details/4787670
SSL证书制作:http://blog.chinaunix.net/uid-7591044-id-1742977.html
0 0
- libcurl使用认证证书 https认证
- libcurl使用认证证书 https认证
- Android Https证书认证
- 使用okhttp忽略https的证书认证
- Https的认证证书简介
- Tomcat服务器配置https认证(使用keytool生成证书)
- 使用证书加密认证
- android SSL证书认证、SSL双向认证、https访问;
- keytool+tomcat配置HTTPS双向证书认证
- keytool+tomcat配置HTTPS双向证书认证
- keytool+tomcat配置HTTPS双向证书认证
- keytool+tomcat配置HTTPS双向证书认证
- Tomcat7 配置Https双向证书认证
- keytool+tomcat7配置HTTPS双向证书认证
- keytool+tomcat配置HTTPS双向证书认证
- keytool+tomcat配置HTTPS双向证书认证
- keytool+tomcat配置HTTPS双向证书认证
- keytool+tomcat配置https双向证书认证
- 如果查看应用性能图表是一种信仰
- C++内存管理详解
- UIButton
- SAX解析XML 详解
- 高德导航HOME键后台运行会报错
- libcurl使用认证证书 https认证
- 将json转换成bean
- dos命令大全
- Webdriver自动化测试使用Xpath-Helper调试页面元素的xpath
- Away3D 4.0环境配置
- 百度云消息推送
- 透过汇编另眼看世界之多继承下的虚函数函数调用
- volley网络通信框架研究
- xcode常用插件