fix for some neon version and ssl allowed even with bad server certificates
(and old patch fixing tests)
This commit is contained in:
parent
6f051a105b
commit
d8dd7e83aa
21
src/soap.c
21
src/soap.c
|
@ -30,6 +30,14 @@ static void collector(void *ud, const char *data, size_t len)
|
|||
ne_buffer_append(buf, data, len);
|
||||
}
|
||||
|
||||
int ssl_verify_fn(void *userdata, int failures, const ne_ssl_certificate *cert)
|
||||
{
|
||||
/* we consider every server certificate as ok;
|
||||
* easy debugging, lousy security
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char* soap_request(char *url, char *body, char *content_type)
|
||||
{
|
||||
|
@ -42,13 +50,19 @@ char* soap_request(char *url, char *body, char *content_type)
|
|||
int rc;
|
||||
|
||||
rc = ne_uri_parse(url, &parsed_uri);
|
||||
if (!rc) {
|
||||
if (rc) {
|
||||
fprintf(stderr, "ne_uri_parse failed\n");
|
||||
return NULL;
|
||||
}
|
||||
if (strcmp(parsed_uri.scheme, "https") == 0 && ! parsed_uri.port) {
|
||||
/* some neon version are buggy and don't set a default port */
|
||||
parsed_uri.port = 443;
|
||||
}
|
||||
|
||||
ne_sock_init();
|
||||
sess = ne_session_create(parsed_uri.scheme, parsed_uri.host,
|
||||
parsed_uri.port);
|
||||
ne_ssl_set_verify(sess, ssl_verify_fn, NULL);
|
||||
|
||||
req = ne_request_create(sess, "POST", parsed_uri.path);
|
||||
ne_add_response_body_reader(req, ne_accept_2xx, collector, buf);
|
||||
|
@ -57,7 +71,9 @@ char* soap_request(char *url, char *body, char *content_type)
|
|||
ne_set_request_body_buffer(req, body, strlen(body));
|
||||
|
||||
rc = ne_request_dispatch(req);
|
||||
if (!rc) {
|
||||
if (rc) {
|
||||
fprintf(stderr, "ne_request_dispatch failed, %d\n", rc);
|
||||
fprintf(stderr, "Error was: %s\n", ne_get_error(sess));
|
||||
ne_request_destroy(req);
|
||||
ne_session_destroy(sess);
|
||||
return NULL;
|
||||
|
@ -65,6 +81,7 @@ char* soap_request(char *url, char *body, char *content_type)
|
|||
|
||||
status = ne_get_status(req);
|
||||
if (status->code != 200) {
|
||||
fprintf(stderr, "status->code = %d\n", status->code);
|
||||
ne_request_destroy(req);
|
||||
ne_session_destroy(sess);
|
||||
return NULL;
|
||||
|
|
Reference in New Issue