It's not clear if you built libcurl as a static library to begin with. And not clear if you built OpenSSL as a static or shared library.
And you must load curltest(as that is the name of the module) not curl. On Fri, Sep 14, 2012 at 8:28 PM, Indtiny s <indt...@gmail.com> wrote: > > > > Hi, > > yes I'm able to built the openssl1.0.1c version for android and got the > shared libraries . > > Now I want to use the same with curl , first I built simple curl application > and tested and it worked now I tried to include the openssl . > below is the android.mk file which I have written to include openssl > libraries for the curl code . > > > LOCAL_PATH:= $(call my-dir) > > CFLAGS := -Wpointer-arith -Wwrite-strings -Wunused -Winline \ > -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long > \ > -Wfloat-equal -Wno-multichar -Wsign-compare -Wno-format-nonliteral \ > -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement \ > -Wno-system-headers -DHAVE_CONFIG_H > > include $(CLEAR_VARS) > > ## Crypto lib > include $(CLEAR_VARS) > LOCAL_MODULE := xcryptox > LOCAL_SRC_FILES := openssl/lib/libcrypto.so > LOCAL_C_INCLUDES := $(LOCAL_PATH)/openssl/includes/openssl > include $(PREBUILT_SHARED_LIBRARY) > # > ### SSL lib > include $(CLEAR_VARS) > LOCAL_MODULE := xsslx > LOCAL_SRC_FILES := openssl/libssl/lib/libssl.so > LOCAL_C_INCLUDES := $(LOCAL_PATH)/openssl/includes/openssl > include $(PREBUILT_SHARED_LIBRARY) > > include $(LOCAL_PATH)/curl/lib/Makefile.inc . > > LOCAL_SRC_FILES := $(addprefix curl/lib/,$(CSOURCES)) > LOCAL_CFLAGS += $(CFLAGS) > LOCAL_C_INCLUDES += $(LOCAL_PATH)/curl/include/ > > LOCAL_COPY_HEADERS_TO := libcurl > LOCAL_COPY_HEADERS := $(addprefix curl/include/curl/,$(HHEADERS)) > > LOCAL_MODULE:= libcurl > > include $(BUILD_STATIC_LIBRARY) > > # Build shared library now > # curltest > > include $(CLEAR_VARS) > > LOCAL_MODULE := curltest > LOCAL_SRC_FILES := curltest.c > LOCAL_STATIC_LIBRARIES := libcurl > LOCAL_C_INCLUDES += $(LOCAL_PATH)/curl/include > include $(BUILD_SHARED_LIBRARY) > > And below is my C curtest code with ssl include . > > > > #include <string.h> > #include <jni.h> > #include <stdio.h> > #include <stdlib.h> > #include "curl_config.h" > #include "curl/curl.h" > > typedef struct pageInfo_t { > char *data; > int len; > } pageInfo_t; > > static size_t > HTTPData(void *buffer, size_t size, size_t nmemb, void *userData) { > int len = size * nmemb; > pageInfo_t *page = (pageInfo_t *)userData; > > > if (buffer && page->data && (page->len + len < (16 * 1024)) ) { > memcpy(&page->data[page->len], buffer, len); > page->len += len; > } > return len; > } > > //Inteface funciton that will recieve web page fom Java > jstring > Java_com_mtterra_curltest_curltest_JNIGetWebpage( JNIEnv* env, > jobject entryObject, > jstring webpageJStr ) > { > pageInfo_t page; > CURL *curl; > CURLcode res; > char *buffer; > > static const char *pCertFile = "/sdcared/indu/openssl/testcert.pem"; > static const char *pCACertFile="/sdcared/indu/openssl/cacert.pem"; > > const char *pKeyName; > const char *pKeyType; > > const char *pEngine; > const jbyte *webpage; > pKeyName = "/sdcared/indu/openssl/testkey.pem"; > pKeyType = "PEM"; > pEngine = NULL; > webpage = (*env)->GetStringUTFChars(env, webpageJStr, NULL); > if (webpage == NULL) { > return NULL; /* OutOfMemoryError already thrown */ > } > > page.data = (char *)malloc(16 * 1024); > page.len = 0; > if (page.data) > memset(page.data, 32, 16 * 1024); > > buffer = (char *)malloc(1024); > > curl = curl_easy_init(); > if(curl) { > curl_easy_setopt(curl, CURLOPT_URL, webpage); > curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HTTPData); > curl_easy_setopt(curl, CURLOPT_WRITEDATA, &page); > > /* since PEM is default, we needn't set it for PEM */ > curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM"); > > /* set the cert for client authentication */ > curl_easy_setopt(curl,CURLOPT_SSLCERT,pCertFile); > > /* if we use a key stored in a crypto engine, > we must set the key type to "ENG" */ > curl_easy_setopt(curl,CURLOPT_SSLKEYTYPE,pKeyType); > > /* set the private key (file or ID in engine) */ > curl_easy_setopt(curl,CURLOPT_SSLKEY,pKeyName); > > /* set the file with the certs vaildating the server */ > curl_easy_setopt(curl,CURLOPT_CAINFO,pCACertFile); > > /* disconnect if we can't validate server's cert */ > curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,1L); > > > res = curl_easy_perform(curl); > /* always cleanup */ > curl_easy_cleanup(curl); > (*env)->ReleaseStringUTFChars(env, webpageJStr, webpage); > if(res == 0) { > if (buffer) { > page.data[page.len < 256 ? page.len : 256] = '\0'; > sprintf(buffer, "pagedata(%d): %s. done.\n", page.len, page.data); > return (*env)->NewStringUTF(env, buffer); > } > } > sprintf(buffer, "Result %d", res); > return (*env)->NewStringUTF(env, buffer); > } else { > return (*env)->NewStringUTF(env, "Unable to init cURL"); > } > } > > > I tried to run this but I get the response as just Result at the my java > application code .. is the above method is the proper way to include the > openssl in android..? > in my java code I'm just loading System.loadLibrary("curl"); > > Rgds > Indu ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org