SHOW:
|
|
- or go back to the newest paste.
| 1 | #define APPLE_CERT_NAME "certs/apple.cer" | |
| 2 | #define APPLE_CERT_TYPE "PK12" | |
| 3 | #define APPLE_PUSH_SERVICE_URL "gateway.sandbox.push.apple.com:2195" | |
| 4 | ||
| 5 | CURLcode c; | |
| 6 | c = curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL); | |
| 7 | if (c != CURLE_OK) | |
| 8 | WARNX("curl_easy_setopt error CURLOPT_USE_SLL %s", curl_easy_strerror(c));
| |
| 9 | ||
| 10 | c = curl_easy_setopt(curl, CURLOPT_SSLCERT, APPLE_CERT_NAME); | |
| 11 | if (c != CURLE_OK) | |
| 12 | WARNX("curl_easy_setopt error CURLOPT_SSLCERT: %s", curl_easy_strerror(c));
| |
| 13 | c = curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, APPLE_CERT_TYPE); | |
| 14 | if (c != CURLE_OK) | |
| 15 | WARNX("curl_easy_setopt error CURLOPT_SSL_CERTTYPE: %s", curl_easy_strerror(c));
| |
| 16 | ||
| 17 | curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L); | |
| 18 | curl_easy_setopt(curl, CURLOPT_URL, APPLE_PUSH_SERVICE_URL); | |
| 19 | ||
| 20 | // curl_easy_perform | |
| 21 | ||
| 22 | size_t sent, rec = 0; | |
| 23 | ccode = curl_easy_send(curl, ((struct ios_push_request *)buffer->aux_data)->sbuffer, ((struct ios_push_request *)buffer->aux_data)->request_size, &sent); | |
| 24 | if (ccode != CURLE_OK) | |
| 25 | WARNX("curl_easy_send %s", curl_easy_strerror(ccode));
| |
| 26 | ||
| 27 | LOG("----- Sent %lu bytes from %lu", sent, ((struct ios_push_request *)buffer->aux_data)->request_size); // it always sends all the data
| |
| 28 | ||
| 29 | sleep(3); | |
| 30 | ccode = curl_easy_recv(curl, buf, 1024, &rec); | |
| 31 | if (ccode != CURLE_OK) | |
| 32 | WARNX("curl_easy_recv %s", curl_easy_strerror(ccode)); // unsupported protocol |