Implement internal API for host verification 19/225319/3
authorSeonah Moon <seonah1.moon@samsung.com>
Wed, 19 Feb 2020 05:25:36 +0000 (14:25 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Thu, 20 Feb 2020 11:54:19 +0000 (20:54 +0900)
Change-Id: I0362a6263d177363580ecb95cf6223b611a1b896

12 files changed:
agent/download-agent-dl-info.c
agent/download-agent-interface.c
agent/download-agent-plugin-libcurl.c
agent/include/download-agent-dl-info.h
agent/include/download-agent-interface.h
packaging/download-provider.spec
provider-interface/download-provider-interface.c
provider-interface/include/download-provider-interface.h
provider/download-provider-client.c
provider/download-provider-plugin-download-agent.c
provider/include/download-provider-client.h
provider/include/download-provider.h

index 0b313e5..e866836 100644 (file)
@@ -282,11 +282,14 @@ da_ret_t copy_user_input_data(da_info_t *da_info, const char *url,
                        req_info->temp_file_path = strdup(ext_data->temp_file_path);
                if (ext_data->pkg_name)
                        req_info->pkg_name = strdup(ext_data->pkg_name);
-               req_info->network_bonding = ext_data->network_bonding;
                if (ext_data->user_req_data)
                        req_info->user_req_data = ext_data->user_req_data;
                if (ext_data->user_client_data)
                        req_info->user_client_data = ext_data->user_client_data;
+
+               req_info->network_bonding = ext_data->network_bonding;
+               req_info->disable_verify_host = ext_data->disable_verify_host;
+
                da_info->req_info = req_info;
        }
        if (da_cb_data) {
index 58f865b..a01e328 100755 (executable)
@@ -88,6 +88,7 @@ int da_start_download(const char *url, req_data_t *ext_data,
                DA_LOGI("user_req_data[%p]", ext_data->user_req_data);
        if (ext_data->user_client_data)
                        DA_LOGI("user_client_data[%p]", ext_data->user_client_data);
+       DA_LOGD("disable_verify_host[%d]", ext_data->disable_verify_host);
 
        ret = get_available_da_id(&da_id);
        if (ret != DA_RESULT_OK)
index 8c7ddc1..90ce634 100755 (executable)
@@ -437,6 +437,7 @@ da_ret_t PI_http_start(da_info_t *da_info)
        struct curl_httppost* post = NULL;
        struct curl_slist *headers = DA_NULL;
        char err_buffer[CURL_ERROR_SIZE] = {0,};
+       int disable_verify_host = 0;
 
        DA_LOGV("");
 #ifdef _RAF_SUPPORT
@@ -450,6 +451,8 @@ da_ret_t PI_http_start(da_info_t *da_info)
        http_info = da_info->http_info;
        NULL_CHECK_GOTO(http_info);
 
+       disable_verify_host = da_info->req_info->disable_verify_host;
+
        http_method = http_info->http_method;
        ret = init_http_msg_t(&http_msg);
        if (ret != DA_RESULT_OK)
@@ -509,6 +512,7 @@ da_ret_t PI_http_start(da_info_t *da_info)
        curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, err_buffer);
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
+       curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, disable_verify_host ? 0L : 2L);
 #ifdef _CA_CERT
        curl_easy_setopt(curl, CURLOPT_CAINFO, _CA_CERT);
 #endif
index 6e0e674..10d2f87 100644 (file)
@@ -65,6 +65,7 @@ typedef struct {
        char *temp_file_path;
        char *pkg_name;
        int network_bonding;
+       int disable_verify_host;
        void *user_req_data;
        void *user_client_data;
 } req_info_t;
index 2b3495c..2e3e4b2 100755 (executable)
@@ -56,6 +56,7 @@ typedef struct {
        const char *etag;
        const char *pkg_name;
        int network_bonding;
+       int disable_verify_host;
        void *user_req_data;
        void *user_client_data;
 } req_data_t;
index 49c1294..7daf3b6 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       download-provider
 Summary:    Download the contents in background
-Version:    2.1.119
+Version:    2.1.120
 Release:    0
 Group:      Development/Libraries
 License:    Apache-2.0
index 8146447..2e9e961 100755 (executable)
@@ -1715,3 +1715,9 @@ int dp_interface_remove_http_header_field(const int id,
 {
        return __dp_ipc_set_string(id, DP_SEC_UNSET, DP_PROP_HTTP_HEADER, field, __FUNCTION__);
 }
+
+int dp_interface_set_verify_host(const int id, int enable)
+{
+       return __dp_ipc_set_int(id, DP_SEC_SET, DP_PROP_VERIFY_HOST,
+               enable, __FUNCTION__);
+}
index aaa893c..cb8b247 100755 (executable)
@@ -135,6 +135,8 @@ EXPORT_API int dp_interface_set_notification_description(const int id, const cha
 EXPORT_API int dp_interface_get_notification_description(const int id, char **description);
 EXPORT_API int dp_interface_set_notification_type(const int id, int type);
 EXPORT_API int dp_interface_get_notification_type(const int id, int *type);
+
+EXPORT_API int dp_interface_set_verify_host(const int id, int enable);
 #ifdef __cplusplus
 }
 #endif
index aa41601..d6a7954 100755 (executable)
@@ -250,6 +250,8 @@ char *dp_print_property(unsigned property)
                return "HTTP_HEADERS";
        case DP_PROP_HTTP_HEADER:
                return "HTTP_HEADER";
+       case DP_PROP_VERIFY_HOST:
+               return "VERIFY_HOST";
        default:
                break;
        }
@@ -1293,6 +1295,16 @@ static int __dp_request_set_info(dp_client_slots_fmt *slot, dp_ipc_fmt *ipc_info
                        free(header_value);
                        break;
                }
+       case DP_PROP_VERIFY_HOST:
+       {
+               int recv_int = -1;
+               errorcode = __dp_request_read_int(client->channel, ipc_info, &recv_int);
+               if (errorcode == DP_ERROR_NONE) {
+                       if (requestp != NULL)
+                               requestp->disable_verify_host = recv_int ? 0 : 1;
+               }
+               break;
+       }
        default:
                errorcode = DP_ERROR_INVALID_PARAMETER;
                break;
index d61f63e..225b31f 100755 (executable)
@@ -915,6 +915,7 @@ int dp_start_agent_download(void *slot, void *request)
        } else
                req_data->network_bonding = user_network_bonding;
 
+       req_data->disable_verify_host = base_req->disable_verify_host;
        req_data->pkg_name = base_slot->pkgname;
 
        // get headers list from header table(DB)
index 6ce8d14..31ed0cb 100644 (file)
@@ -36,6 +36,7 @@ typedef struct {
        dp_content_type content_type;
        int noti_type;
        int noti_priv_id;
+       int disable_verify_host; // tv only, internal API
        void *next;
 } dp_request_fmt;
 
index 7beda34..41c12ea 100755 (executable)
@@ -151,6 +151,7 @@ typedef enum {
        DP_PROP_PAUSE,
        DP_PROP_CANCEL,
        DP_PROP_DESTROY,
+       DP_PROP_VERIFY_HOST
 } dp_ipc_property_defs;
 
 typedef enum {