1CURLOPT_PROXY_PINNEDPUBLICKEcYu(r3l)_easy_setopt optCiUoRnLsOPT_PROXY_PINNEDPUBLICKEY(3)
2
3
4

NAME

6       CURLOPT_PROXY_PINNEDPUBLICKEY - pinned public key for https proxy
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_PINNEDPUBLICKEY, char *pinnedpubkey);
12

DESCRIPTION

14       Pass a pointer to a null-terminated string as parameter. The string can
15       be the file name of your pinned public key. The file format expected is
16       "PEM"  or  "DER".   The string can also be any number of base64 encoded
17       sha256 hashes preceded by "sha256//" and separated by ";"
18
19       When negotiating a TLS or SSL connection, the https proxy sends a  cer‐
20       tificate  indicating  its identity. A public key is extracted from this
21       certificate and if it does not exactly match the public key provided to
22       this option, curl will abort the connection before sending or receiving
23       any data.
24
25       On mismatch, CURLE_SSL_PINNEDPUBKEYNOTMATCH is returned.
26
27       The application does not have to keep the string around  after  setting
28       this option.
29

DEFAULT

31       NULL
32

PROTOCOLS

34       All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
35

EXAMPLE

37       CURL *curl = curl_easy_init();
38       if(curl) {
39         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
40         curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443");
41         curl_easy_setopt(curl, CURLOPT_PROXY_PINNEDPUBLICKEY,
42         "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjAa3HWY3tvRMwE=;sha256//t62CeU2tQiqkexU74Gxa2eg7fRbEgoChTociMee9wno=");
43
44         /* Perform the request */
45         curl_easy_perform(curl);
46       }
47

PUBLIC KEY EXTRACTION

49       If you do not have the https proxy server's public key file you can ex‐
50       tract it from the https proxy server's certificate.
51       # retrieve the server's certificate if you do not already have it
52       #
53       # be sure to examine the certificate to see if it is what you expected
54       #
55       # Windows-specific:
56       # - Use NUL instead of /dev/null.
57       # - OpenSSL may wait for input instead of disconnecting. Hit enter.
58       # - If you do not have sed, then just copy the certificate into a file:
59       #   Lines from -----BEGIN CERTIFICATE----- to -----END CERTIFICATE-----.
60       #
61       openssl s_client -servername www.example.com -connect www.example.com:443 < /dev/null | sed -n "/-----BEGIN/,/-----END/p" > www.example.com.pem
62
63       # extract public key in pem format from certificate
64       openssl x509 -in www.example.com.pem -pubkey -noout > www.example.com.pubkey.pem
65
66       # convert public key from pem to der
67       openssl asn1parse -noout -inform pem -in www.example.com.pubkey.pem -out www.example.com.pubkey.der
68
69       # sha256 hash and base64 encode der to string for use
70       openssl dgst -sha256 -binary www.example.com.pubkey.der | openssl base64
71       The public key in PEM format contains  a  header,  base64  data  and  a
72       footer:
73       -----BEGIN PUBLIC KEY-----
74       [BASE 64 DATA]
75       -----END PUBLIC KEY-----
76

AVAILABILITY

78       PEM/DER support:
79
80         7.52.0: GSKit, GnuTLS, NSS, OpenSSL, mbedtls, wolfSSL
81
82       sha256 support:
83
84         7.52.0: GnuTLS, NSS, OpenSSL, mbedtls, wolfSSL
85
86       Other SSL backends not supported.
87

RETURN VALUE

89       Returns  CURLE_OK  if  TLS  enabled,  CURLE_UNKNOWN_OPTION  if  not, or
90       CURLE_OUT_OF_MEMORY if there was insufficient heap space.
91

SEE ALSO

93       CURLOPT_PROXY_SSL_VERIFYPEER(3), CURLOPT_PROXY_SSL_VERIFYHOST(3),  CUR‐
94       LOPT_PROXY_CAINFO(3), CURLOPT_PROXY_CAPATH(3),
95
96
97
98libcurl 7.85.0                   May 17, 2022 CURLOPT_PROXY_PINNEDPUBLICKEY(3)
Impressum