Artifactspublic-v0

curl

master
ply4 git calls145 ms289 KiB2 cachedprotocol v2
139 lines3.7 KiBRaw

NAME

CURLOPT_PROXY_PINNEDPUBLICKEY - pinned public key for https proxy

SYNOPSIS

c
#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_PINNEDPUBLICKEY,
                          char *pinnedpubkey);

DESCRIPTION

Pass a pointer to a null-terminated string as parameter. The string can be the filename of your pinned public key. The file format expected is "PEM" or "DER". The string can also be any number of base64 encoded sha256 hashes preceded by "sha256//" and separated by ";"

When negotiating a TLS or SSL connection, the https proxy sends a certificate indicating its identity. A public key is extracted from this certificate and if it does not exactly match the public key provided to this option, libcurl aborts the connection before sending or receiving any data.

On mismatch, CURLE_SSL_PINNEDPUBKEYNOTMATCH is returned.

The application does not have to keep the string around after setting this option.

Using this option multiple times makes the last set string override the previous ones. Set it to NULL to disable its use again.

DEFAULT

NULL

%PROTOCOLS%

EXAMPLE

c
int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
    curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example:443");
    curl_easy_setopt(curl, CURLOPT_PROXY_PINNEDPUBLICKEY,
                     "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjA"
                     "a3HWY3tvRMwE=;sha256//t62CeU2tQiqkexU74"
                     "Gxa2eg7fRbEgoChTociMee9wno=");

    /* Perform the request */
    result = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
  }
}

PUBLIC KEY EXTRACTION

If you do not have the https proxy server's public key file you can extract it from the https proxy server's certificate.

c
# retrieve the server's certificate if you do not already have it
#
# be sure to examine the certificate to see if it is what you expected
#
# Windows-specific:
# - Use NUL instead of /dev/null.
# - OpenSSL may wait for input instead of disconnecting. Hit enter.
# - If you do not have sed, then copy the certificate into a file:
#   Lines from -----BEGIN CERTIFICATE----- to -----END CERTIFICATE-----.
#
openssl s_client -servername www.example.com -connect www.example.com:443 \
  < /dev/null | sed -n "/-----BEGIN/,/-----END/p" > www.example.com.pem

# extract public key in pem format from certificate
openssl x509 -in www.example.com.pem -pubkey -noout > www.example.com.pubkey.pem

# convert public key from pem to der
openssl asn1parse -noout -inform pem -in www.example.com.pubkey.pem \
  -out www.example.com.pubkey.der

# sha256 hash and base64 encode der to string for use
openssl dgst -sha256 -binary www.example.com.pubkey.der | openssl base64

The public key in PEM format contains a header, base64 data and a footer:

c
-----BEGIN PUBLIC KEY-----
[BASE 64 DATA]
-----END PUBLIC KEY-----

HISTORY

PEM/DER support:

7.52.0: GnuTLS, OpenSSL, mbedTLS, wolfSSL

sha256 support:

7.52.0: GnuTLS, OpenSSL, mbedTLS, wolfSSL

Other SSL backends not supported.

%AVAILABILITY%

RETURN VALUE

curl_easy_setopt(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3).

1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_PROXY_PINNEDPUBLICKEY
5Section: 3
6Source: libcurl
7See-also:
8 - CURLOPT_PINNEDPUBLICKEY (3)
9 - CURLOPT_PROXY_CAINFO (3)
10 - CURLOPT_PROXY_CAPATH (3)
11 - CURLOPT_PROXY_SSL_VERIFYHOST (3)
12 - CURLOPT_PROXY_SSL_VERIFYPEER (3)
13Protocol:
14 - TLS
15TLS-backend:
16 - OpenSSL
17 - GnuTLS
18 - mbedTLS
19 - wolfSSL
20Added-in: 7.52.0
21---
23# NAME
25CURLOPT_PROXY_PINNEDPUBLICKEY - pinned public key for https proxy
27# SYNOPSIS
29~~~c
30#include <curl/curl.h>
32CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_PINNEDPUBLICKEY,
33 char *pinnedpubkey);
34~~~
36# DESCRIPTION
38Pass a pointer to a null-terminated string as parameter. The string can be the
39filename of your pinned public key. The file format expected is "PEM" or
40"DER". The string can also be any number of base64 encoded sha256 hashes
41preceded by "sha256//" and separated by ";"
43When negotiating a TLS or SSL connection, the https proxy sends a certificate
44indicating its identity. A public key is extracted from this certificate and
45if it does not exactly match the public key provided to this option, libcurl
46aborts the connection before sending or receiving any data.
48On mismatch, *CURLE_SSL_PINNEDPUBKEYNOTMATCH* is returned.
50The application does not have to keep the string around after setting this
51option.
53Using this option multiple times makes the last set string override the
54previous ones. Set it to NULL to disable its use again.
56# DEFAULT
58NULL
60# %PROTOCOLS%
62# EXAMPLE
64~~~c
65int main(void)
67 CURL *curl = curl_easy_init();
68 if(curl) {
69 CURLcode result;
70 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
71 curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example:443");
72 curl_easy_setopt(curl, CURLOPT_PROXY_PINNEDPUBLICKEY,
73 "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjA"
74 "a3HWY3tvRMwE=;sha256//t62CeU2tQiqkexU74"
75 "Gxa2eg7fRbEgoChTociMee9wno=");
77 /* Perform the request */
78 result = curl_easy_perform(curl);
79 curl_easy_cleanup(curl);
80 }
82~~~
84# PUBLIC KEY EXTRACTION
86If you do not have the https proxy server's public key file you can extract it
87from the https proxy server's certificate.
88~~~c
89# retrieve the server's certificate if you do not already have it
91# be sure to examine the certificate to see if it is what you expected
93# Windows-specific:
94# - Use NUL instead of /dev/null.
95# - OpenSSL may wait for input instead of disconnecting. Hit enter.
96# - If you do not have sed, then copy the certificate into a file:
97# Lines from -----BEGIN CERTIFICATE----- to -----END CERTIFICATE-----.
99openssl s_client -servername www.example.com -connect www.example.com:443 \
100 < /dev/null | sed -n "/-----BEGIN/,/-----END/p" > www.example.com.pem
102# extract public key in pem format from certificate
103openssl x509 -in www.example.com.pem -pubkey -noout > www.example.com.pubkey.pem
105# convert public key from pem to der
106openssl asn1parse -noout -inform pem -in www.example.com.pubkey.pem \
107 -out www.example.com.pubkey.der
109# sha256 hash and base64 encode der to string for use
110openssl dgst -sha256 -binary www.example.com.pubkey.der | openssl base64
111~~~
112The public key in PEM format contains a header, base64 data and a
113footer:
114~~~c
115-----BEGIN PUBLIC KEY-----
116[BASE 64 DATA]
117-----END PUBLIC KEY-----
118~~~
120# HISTORY
122PEM/DER support:
124 7.52.0: GnuTLS, OpenSSL, mbedTLS, wolfSSL
126sha256 support:
128 7.52.0: GnuTLS, OpenSSL, mbedTLS, wolfSSL
130Other SSL backends not supported.
132# %AVAILABILITY%
134# RETURN VALUE
136curl_easy_setopt(3) returns a CURLcode indicating success or error.
138CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
139libcurl-errors(3).
Diagnostics4 git calls · 145 ms
CallStatusSizeTime0145 ms
discover200152 B2 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 · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=2
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 · hit5 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=138
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=5
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.8 KiB138 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1832
git.response.cache=MISS
git.response.duration_ms=138
git.fetch.wants=21e0bd42a336085cc6380ad9b2ec3febb70e0a3d
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=1832
git.pkt.payload.max=1811
git.sideband.band1.bytes=1810
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
a5e3828c8c92c69c
Request
9074e224…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format