cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Port from URI is not taken

From: Sidde Gowda <engowdre_at_hotmail.com>
Date: Thu, 30 Aug 2012 21:44:28 +0000

> From: jmason_at_rim.com
> To: curl-library_at_cool.haxx.se
> Subject: RE: Port from URI is not taken
> Date: Thu, 30 Aug 2012 21:30:09 +0000
>
> QNX, eh? Is this the version of curl shipped with the BlackBerry 10 developer alpha, by any chance? (Or the Playbook SDK?) If something wacky and QNX-related IS going on, we'd like to know about it... (Although it's unlikely.)
>
> The code you quoted looks pretty straightforward - can you print the value of msg->frm_url and port before you call curl_easy_setopt, to make absolutely sure those vars contain what you think they do?
>
> Is the CURL* created with curl_easy_init immediately before calling http_curl_setopt_perform? Any other curl_whatever calls between curl_easy_init and the first curl_easy_setopt?
>
> Can you send the code for http_curl_perform? Maybe something is mucking with the CURL* after you call setopt but before you call curl_easy_perform.

Hi, yes I am calling a function between init() and setopt() to create directories recursively in as specified by the path parameter to store fetched file. Could that be an issue?

My http curl perform is a simple function:

/*
 * http_curl_perform
 */
static CURLcode
http_curl_perform (CURL *curl)
{
    CURLcode curl_rc;

    /* Perform the request */
    curl_rc = curl_easy_perform(curl);

    return(curl_rc);
}

Now, I am seeing another issue when using SSL/TLS. MY requirement is to download crl from ca server as specified by CDP in the ca signed cert. In order to establish SSL connection over http, do I need any other certificate from ca server other than the one I mentioned (signed ca cert). Do we also need client certificate?

Aug 30 21:17:29 [0] DEBUG Fetchd-GENERAL: http_curl_setopt_perform: error [rc 77] buf [error setting certificate verify locations:
  CAfile: /hdp/cert/local/ca/server_cert.crt
  CApath: none
]

Thanks in advance
-Sidde

> ________________________________
> From: curl-library [curl-library-bounces_at_cool.haxx.se] on behalf of Sidde Gowda [engowdre_at_hotmail.com]
> Sent: Thursday, August 30, 2012 4:34 PM
> To: libcurl development
> Subject: RE: Port from URI is not taken
>
>
>
> > Date: Thu, 30 Aug 2012 22:18:06 +0200
> > From: daniel_at_haxx.se
> > To: curl-library_at_cool.haxx.se
> > Subject: Re: Port from URI is not taken
> >
> > On Thu, 30 Aug 2012, Sidde Gowda wrote:
> >
> > > Using port 80, I am getting the html content instead of intended file.
> >
> > Using a proxy? Otherwise, can you please show us a complete example code that
> > repeats this problem for you. Which libcurl version on what OS?
> >
> > --
> >
> > / daniel.haxx.se
>
> I am not using proxy. Version is 7.22.0 on QNX6
>
> /*
> * http_curl_setopt_perform
> */
> static fetchd_rc_t
> http_curl_setopt_perform (CURL *curl,
> FILE *file,
> fetchd_client_msg_t *msg)
> {
> #ifdef DEBUG_FETCH
> char buf[FETCHD_MAX_ERRBUF_LEN];
> #endif
> char srv_cert[FETCHD_MAX_SRVRCERT_LEN];
> uint16_t port;
> CURLcode curl_rc;
> fetchd_rc_t fetchd_rc = FETCHD_RC_OK;
> bool http_need_ssltls = false;
>
> if (msg == NULL) {
> fetchd_rc = FETCHD_RC_INVALID_MSG;
> return(fetchd_rc);
> }
>
> /* parse url and resolve name if needed */
> fetchd_rc = http_curl_parse_resolve_url(msg->frm_ctx_idx,
> msg->frm_url,
> &port,
> &http_need_ssltls);
> if (fetchd_rc != FETCHD_RC_OK) {
> return(fetchd_rc);
> }
>
> #ifdef DEBUG_FETCH
> curl_rc = curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "VERBOSE failed %d", curl_rc);
>
> curl_rc = curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, buf);
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "ERRORBUFFER failed %d", curl_rc);
> #endif
>
> curl_rc = curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "NOPROGRESS failed %d", curl_rc);
>
> curl_rc = curl_easy_setopt(curl, CURLOPT_URL, msg->frm_url);
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "URL failed %d", curl_rc);
>
> curl_rc = curl_easy_setopt(curl, CURLOPT_HEADER, 0L);
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "HEADER failed %d", curl_rc);
>
> curl_rc = curl_easy_setopt(curl, CURLOPT_PORT, port);
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "PORT failed %d", curl_rc);
>
> curl_rc = curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "FOLLOWLOCATION failed %d", curl_rc);
>
> //curl_rc = curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L);
> /* ASSERT_CLASS_LOGICAL */
> //nv_assert(curl_rc == CURLE_OK, "WILDCARDMATCH failed %d", curl_rc);
>
> if (http_need_ssltls) {
> fetchd_rc = http_curl_find_ssltls_cert(msg->frm_ctx_name,
> srv_cert);
> if (fetchd_rc != FETCHD_RC_OK) {
> return(fetchd_rc);
> }
>
> /* Transport Layer Security (TLS) for https service */
> curl_rc = curl_easy_setopt(curl, CURLOPT_USE_SSL,
> (long)CURLUSESSL_ALL);
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "USE_SSL failed %d", curl_rc);
>
> curl_rc = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "VERIFYPEER failed %d", curl_rc);
>
> curl_rc = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "VERIFYHOST failed %d", curl_rc);
>
> curl_rc = curl_easy_setopt(curl, CURLOPT_CAINFO, srv_cert);
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "CAINFO failed %d", curl_rc);
>
> curl_rc = curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "SSLCERTTYPE failed %d", curl_rc);
>
> curl_rc = curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION,
> http_curl_ssl_ctx);
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "CTX_FUNCTION failed %d", curl_rc);
>
> curl_rc = curl_easy_setopt(curl, CURLOPT_SSL_CTX_DATA, NULL);
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "CTX_DATA failed %d", curl_rc);
> }
>
> /* call this function to get a socket */
> curl_rc = curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION,
> http_curl_open_socket);
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "OPENSOCKETFUNCTION failed %d", curl_rc);
>
> curl_rc = curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA,
> (void *)msg->frm_ctx_idx);
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "OPENSOCKETDATA failed %d", curl_rc);
>
> /* write to the file */
> //curl_rc = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
> // http_curl_write_data);
> /* ASSERT_CLASS_LOGICAL */
> //nv_assert(curl_rc == CURLE_OK, "WRITEFUNCTION failed %d", curl_rc);
>
> /* write to the file */
> curl_rc = curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
> /* ASSERT_CLASS_LOGICAL */
> nv_assert(curl_rc == CURLE_OK, "WRITEDATA failed %d", curl_rc);
>
> /* perform the curl request */
> curl_rc = http_curl_perform(curl);
> if (curl_rc != CURLE_OK) {
> #ifdef DEBUG_FETCH
> evl_fetchd_log_general("%s: error [rc %u] buf [%s]",
> __FUNCTION__, curl_rc, buf);
> #endif
> fetchd_rc = FETCHD_RC_CURL_PERFORM_FAIL;
> }
>
> return(fetchd_rc);
> }
>
>
> > -------------------------------------------------------------------
> > List admin: http://cool.haxx.se/list/listinfo/curl-library
> > Etiquette: http://curl.haxx.se/mail/etiquette.html
>
> ---------------------------------------------------------------------
> This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
                                               

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-08-30