aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2013-11-22 10:42:18 +0100
committerTobias Brunner <tobias@strongswan.org>2014-01-23 10:19:30 +0100
commit72a92d4f7d07980dfadb1ebaca740ec50364d33d (patch)
tree78a8721bd8f9cc74e98f36b9f8426dfa2026a8b0 /src
parentccb6758e5b2c0992ffcab4324d51784d8c94b2d1 (diff)
downloadstrongswan-72a92d4f7d07980dfadb1ebaca740ec50364d33d.tar.bz2
strongswan-72a92d4f7d07980dfadb1ebaca740ec50364d33d.tar.xz
curl: Replace spaces in URIs with %20
cURL requires the URIs to be URL-encoded. Apparently, some CAs encode CRL URIs with spaces in them. Fixes #454.
Diffstat (limited to 'src')
-rw-r--r--src/libstrongswan/plugins/curl/curl_fetcher.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/libstrongswan/plugins/curl/curl_fetcher.c b/src/libstrongswan/plugins/curl/curl_fetcher.c
index a8cca98da..644f27709 100644
--- a/src/libstrongswan/plugins/curl/curl_fetcher.c
+++ b/src/libstrongswan/plugins/curl/curl_fetcher.c
@@ -80,7 +80,7 @@ static size_t curl_cb(void *ptr, size_t size, size_t nmemb, cb_data_t *data)
METHOD(fetcher_t, fetch, status_t,
private_curl_fetcher_t *this, char *uri, void *userdata)
{
- char error[CURL_ERROR_SIZE];
+ char error[CURL_ERROR_SIZE], *enc_uri;
status_t status;
cb_data_t data = {
.cb = this->cb,
@@ -92,9 +92,14 @@ METHOD(fetcher_t, fetch, status_t,
*(chunk_t*)userdata = chunk_empty;
}
- if (curl_easy_setopt(this->curl, CURLOPT_URL, uri) != CURLE_OK)
+ /* the URI has to be URL-encoded, we only replace spaces as replacing other
+ * characters (e.g. '/' or ':') would render the URI invalid */
+ enc_uri = strreplace(uri, " ", "%20");
+
+ if (curl_easy_setopt(this->curl, CURLOPT_URL, enc_uri) != CURLE_OK)
{ /* URL type not supported by curl */
- return NOT_SUPPORTED;
+ status = NOT_SUPPORTED;
+ goto out;
}
curl_easy_setopt(this->curl, CURLOPT_ERRORBUFFER, error);
curl_easy_setopt(this->curl, CURLOPT_FAILONERROR, TRUE);
@@ -125,6 +130,12 @@ METHOD(fetcher_t, fetch, status_t,
status = FAILED;
break;
}
+
+out:
+ if (enc_uri != uri)
+ {
+ free(enc_uri);
+ }
return status;
}