1CURLOPT_PROXY_PINNEDPUBLICKEcYu(r3l)_easy_setopt optCiUoRnLsOPT_PROXY_PINNEDPUBLICKEY(3)
2
3
4
6 CURLOPT_PROXY_PINNEDPUBLICKEY - set pinned public key for https proxy
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_PINNEDPUBLICKEY,
12 char *pinnedpubkey);
13
15 Pass a pointer to a zero terminated string as parameter. The string can
16 be the file name of your pinned public key. The file format expected is
17 "PEM" or "DER". The string can also be any number of base64 encoded
18 sha256 hashes preceded by "sha256//" and separated by ";"
19
20 When negotiating a TLS or SSL connection, the https proxy sends a cer‐
21 tificate indicating its identity. A public key is extracted from this
22 certificate and if it does not exactly match the public key provided to
23 this option, curl will abort the connection before sending or receiving
24 any data.
25
26 On mismatch, CURLE_SSL_PINNEDPUBKEYNOTMATCH is returned.
27
28 The application does not have to keep the string around after setting
29 this option.
30
32 NULL
33
35 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
36
38 CURL *curl = curl_easy_init();
39 if(curl) {
40 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
41 curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443");
42 curl_easy_setopt(curl, CURLOPT_PROXY_PINNEDPUBLICKEY,
43 "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjAa3HWY3tvRMwE=;sha256//t62CeU2tQiqkexU74Gxa2eg7fRbEgoChTociMee9wno=");
44
45 /* Perform the request */
46 curl_easy_perform(curl);
47 }
48
50 If you do not have the https proxy server's public key file you can
51 extract it from the https proxy server's certificate.
52 # retrieve the server's certificate if you don't already have it
53 #
54 # be sure to examine the certificate to see if it is what you expected
55 #
56 # Windows-specific:
57 # - Use NUL instead of /dev/null.
58 # - OpenSSL may wait for input instead of disconnecting. Hit enter.
59 # - If you don't have sed, then just copy the certificate into a file:
60 # Lines from -----BEGIN CERTIFICATE----- to -----END CERTIFICATE-----.
61 #
62 openssl s_client -servername www.example.com -connect www.example.com:443 < /dev/null | sed -n "/-----BEGIN/,/-----END/p" > www.example.com.pem
63
64 # extract public key in pem format from certificate
65 openssl x509 -in www.example.com.pem -pubkey -noout > www.example.com.pubkey.pem
66
67 # convert public key from pem to der
68 openssl asn1parse -noout -inform pem -in www.example.com.pubkey.pem -out www.example.com.pubkey.der
69
70 # sha256 hash and base64 encode der to string for use
71 openssl dgst -sha256 -binary www.example.com.pubkey.der | openssl base64
72 The public key in PEM format contains a header, base64 data and a
73 footer:
74 -----BEGIN PUBLIC KEY-----
75 [BASE 64 DATA]
76 -----END PUBLIC KEY-----
77
79 PEM/DER support:
80
81 7.52.0: GSKit, GnuTLS, NSS, OpenSSL, PolarSSL, mbedtls, wolf‐
82 SSL/CyaSSL
83
84 sha256 support:
85
86 7.52.0: GnuTLS, NSS, OpenSSL, PolarSSL, mbedtls, wolfSSL/CyaSSL
87
88 Other SSL backends not supported.
89
91 Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or
92 CURLE_OUT_OF_MEMORY if there was insufficient heap space.
93
95 CURLOPT_PROXY_SSL_VERIFYPEER(3), CURLOPT_PROXY_SSL_VERIFYHOST(3), CUR‐
96 LOPT_PROXY_CAINFO(3), CURLOPT_PROXY_CAPATH(3),
97
98
99
100libcurl 7.64.0 May 31, 2017 CURLOPT_PROXY_PINNEDPUBLICKEY(3)