Artifactspublic-v0

curl

master
ply4 git calls491 ms288 KiB2 cachedprotocol v2
130 lines3.0 KiBRaw

NAME

CURLOPT_SSL_CTX_DATA - pointer passed to SSL context callback

SYNOPSIS

c
#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_CTX_DATA, void *pointer);

DESCRIPTION

Data pointer to pass to the SSL context callback set by the option CURLOPT_SSL_CTX_FUNCTION(3), this is the pointer you get as third parameter.

DEFAULT

NULL

%PROTOCOLS%

EXAMPLE

c
/* OpenSSL specific */

#include <openssl/ssl.h>
#include <curl/curl.h>
#include <stdio.h>

static CURLcode sslctx_function(CURL *curl, void *sslctx, void *pointer)
{
  X509_STORE *store;
  X509 *cert = NULL;
  BIO *bio;
  char *mypem = pointer;
  /* get a BIO */
  bio = BIO_new_mem_buf(mypem, -1);
  /* use it to read the PEM formatted certificate from memory into an
   * X509 structure that SSL can use
   */
  PEM_read_bio_X509(bio, &cert, 0, NULL);
  if(!cert)
    printf("PEM_read_bio_X509 failed...\n");

  /* get a pointer to the X509 certificate store (which may be empty) */
  store = SSL_CTX_get_cert_store((SSL_CTX *)sslctx);

  /* add our certificate to this store */
  if(X509_STORE_add_cert(store, cert) == 0)
    printf("error adding certificate\n");

  /* decrease reference counts */
  X509_free(cert);
  BIO_free(bio);

  /* all set to go */
  return CURLE_OK;
}

int main(void)
{
  CURL *curl;
  CURLcode result;
  /* CA cert in PEM format, replace the XXXs */
  const char *mypem =
    "-----BEGIN CERTIFICATE-----\n"
    "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"
    "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"
    "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"
    "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"
    "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"
    "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"
    "-----END CERTIFICATE-----\n";

  curl_global_init(CURL_GLOBAL_ALL);
  curl = curl_easy_init();

  curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
  curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");

  curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function);
  curl_easy_setopt(curl, CURLOPT_SSL_CTX_DATA, mypem);
  result = curl_easy_perform(curl);
  if(result == CURLE_OK)
    printf("*** transfer succeeded ***\n");
  else
    printf("*** transfer failed ***\n");

  curl_easy_cleanup(curl);
  curl_global_cleanup();
  return (int)result;
}

HISTORY

Added in 7.11.0 for OpenSSL, in 7.42.0 for wolfSSL, in 7.54.0 for mbedTLS.

%AVAILABILITY%

RETURN VALUE

CURLE_OK if supported; or an error such as:

CURLE_NOT_BUILT_IN - Not supported by the SSL backend

CURLE_UNKNOWN_OPTION

1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_SSL_CTX_DATA
5Section: 3
6Source: libcurl
7See-also:
8 - CURLOPT_SSLVERSION (3)
9 - CURLOPT_SSL_CTX_FUNCTION (3)
10Protocol:
11 - TLS
12TLS-backend:
13 - OpenSSL
14 - wolfSSL
15 - mbedTLS
16Added-in: 7.10.6
17---
19# NAME
21CURLOPT_SSL_CTX_DATA - pointer passed to SSL context callback
23# SYNOPSIS
25~~~c
26#include <curl/curl.h>
28CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_CTX_DATA, void *pointer);
29~~~
31# DESCRIPTION
33Data *pointer* to pass to the SSL context callback set by the option
34CURLOPT_SSL_CTX_FUNCTION(3), this is the pointer you get as third
35parameter.
37# DEFAULT
39NULL
41# %PROTOCOLS%
43# EXAMPLE
45~~~c
46/* OpenSSL specific */
48#include <openssl/ssl.h>
49#include <curl/curl.h>
50#include <stdio.h>
52static CURLcode sslctx_function(CURL *curl, void *sslctx, void *pointer)
54 X509_STORE *store;
55 X509 *cert = NULL;
56 BIO *bio;
57 char *mypem = pointer;
58 /* get a BIO */
59 bio = BIO_new_mem_buf(mypem, -1);
60 /* use it to read the PEM formatted certificate from memory into an
61 * X509 structure that SSL can use
62 */
63 PEM_read_bio_X509(bio, &cert, 0, NULL);
64 if(!cert)
65 printf("PEM_read_bio_X509 failed...\n");
67 /* get a pointer to the X509 certificate store (which may be empty) */
68 store = SSL_CTX_get_cert_store((SSL_CTX *)sslctx);
70 /* add our certificate to this store */
71 if(X509_STORE_add_cert(store, cert) == 0)
72 printf("error adding certificate\n");
74 /* decrease reference counts */
75 X509_free(cert);
76 BIO_free(bio);
78 /* all set to go */
79 return CURLE_OK;
82int main(void)
84 CURL *curl;
85 CURLcode result;
86 /* CA cert in PEM format, replace the XXXs */
87 const char *mypem =
88 "-----BEGIN CERTIFICATE-----\n"
89 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"
90 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"
91 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"
92 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"
93 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"
94 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"
95 "-----END CERTIFICATE-----\n";
97 curl_global_init(CURL_GLOBAL_ALL);
98 curl = curl_easy_init();
100 curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
101 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
102 curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
104 curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function);
105 curl_easy_setopt(curl, CURLOPT_SSL_CTX_DATA, mypem);
106 result = curl_easy_perform(curl);
107 if(result == CURLE_OK)
108 printf("*** transfer succeeded ***\n");
109 else
110 printf("*** transfer failed ***\n");
112 curl_easy_cleanup(curl);
113 curl_global_cleanup();
114 return (int)result;
116~~~
118# HISTORY
120Added in 7.11.0 for OpenSSL, in 7.42.0 for wolfSSL, in 7.54.0 for mbedTLS.
122# %AVAILABILITY%
124# RETURN VALUE
126CURLE_OK if supported; or an error such as:
128CURLE_NOT_BUILT_IN - Not supported by the SSL backend
130CURLE_UNKNOWN_OPTION
Diagnostics4 git calls · 491 ms
CallStatusSizeTime0491 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=3
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=486
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2001.3 KiB486 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1359
git.response.cache=MISS
git.response.duration_ms=486
git.fetch.wants=c6521622b9fd5031e4b5a81ff7c199e3da215bf3
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1359
git.pkt.payload.max=1338
git.sideband.band1.bytes=1337
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e32f71f95e8821
Request
176b9d67…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format