Update to 7.44.0
[platform/upstream/curl.git] / docs / libcurl / opts / CURLOPT_PINNEDPUBLICKEY.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2  "http://www.w3.org/TR/html4/loose.dtd">
3 <html><head>
4 <title>CURLOPT_PINNEDPUBLICKEY man page</title>
5 <meta name="generator" content="roffit">
6 <STYLE type="text/css">
7 pre {
8   overflow: auto;
9   margin: 0;
10 }
11
12 P.level0, pre.level0 {
13  padding-left: 2em;
14 }
15
16 P.level1, pre.level1 {
17  padding-left: 4em;
18 }
19
20 P.level2, pre.level2 {
21  padding-left: 6em;
22 }
23
24 span.emphasis {
25  font-style: italic;
26 }
27
28 span.bold {
29  font-weight: bold;
30 }
31
32 span.manpage {
33  font-weight: bold;
34 }
35
36 h2.nroffsh {
37  background-color: #e0e0e0;
38 }
39
40 span.nroffip {
41  font-weight: bold;
42  font-size: 120%;
43  font-family: monospace;
44 }
45
46 p.roffit {
47  text-align: center;
48  font-size: 80%;
49 }
50 </STYLE>
51 </head><body>
52
53 <p class="level0"><a name="NAME"></a><h2 class="nroffsh">NAME</h2>
54 <p class="level0">CURLOPT_PINNEDPUBLICKEY - set pinned public key <a name="SYNOPSIS"></a><h2 class="nroffsh">SYNOPSIS</h2>
55 <p class="level0">&#35;include &lt;curl/curl.h&gt; 
56 <p class="level0">CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PINNEDPUBLICKEY, char *pinnedpubkey); <a name="DESCRIPTION"></a><h2 class="nroffsh">DESCRIPTION</h2>
57 <p class="level0">Pass a pointer to a zero terminated string as parameter. The string can be the file name 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 seperated by ";" 
58 <p class="level0">When negotiating a TLS or SSL connection, the server 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, curl will abort the connection before sending or receiving any data. <a name="DEFAULT"></a><h2 class="nroffsh">DEFAULT</h2>
59 <p class="level0">NULL <a name="PROTOCOLS"></a><h2 class="nroffsh">PROTOCOLS</h2>
60 <p class="level0">All TLS based protocols: HTTPS, FTPS, IMAPS, POP3, SMTPS etc. <a name="EXAMPLE"></a><h2 class="nroffsh">EXAMPLE</h2>
61 <p class="level0"><pre class="level0">
62 CURL *curl = curl_easy_init();
63 if(curl) {
64 &nbsp; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
65 &nbsp; curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY, "/etc/publickey.der");
66 &nbsp; /* OR
67 &nbsp; curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY, "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjAa3HWY3tvRMwE=;sha256//t62CeU2tQiqkexU74Gxa2eg7fRbEgoChTociMee9wno=");
68 &nbsp; */
69 &nbsp;
70 &nbsp; /* Perform the request */
71 &nbsp; curl_easy_perform(curl);
72 }
73 </pre>
74
75 <p class="level0"><a name="PUBLIC"></a><h2 class="nroffsh">PUBLIC KEY EXTRACTION</h2>
76 <p class="level0">If you do not have the server's public key file you can extract it from the server's certificate. <pre class="level0">
77 &#35; extract public key in pem format from certificate
78 openssl x509 -in www.test.com.pem -pubkey -noout &gt; www.test.com.pubkey.pem
79 &#35; convert public key from pem to der
80 openssl asn1parse -noout -inform pem -in www.test.com.pubkey.pem -out www.test.com.pubkey.der
81 &#35; sha256 hash and base64 encode der to string for use
82 openssl dgst -sha256 -binary www.test.com.pubkey.der | openssl base64
83 </pre>
84
85 <p class="level0">The public key in PEM format contains a header, base64 data and a footer: <pre class="level0">
86 -----BEGIN PUBLIC KEY-----
87 [BASE 64 DATA]
88 -----END PUBLIC KEY-----
89 </pre>
90
91 <p class="level0"><a name="AVAILABILITY"></a><h2 class="nroffsh">AVAILABILITY</h2>
92 <p class="level0">Added in 7.39.0 for OpenSSL, GnuTLS and GSKit. Added in 7.43.0 for NSS and wolfSSL/CyaSSL. sha256 support added in 7.44.0 for OpenSSL, GnuTLS, NSS and wolfSSL/CyaSSL. Other SSL backends not supported. <a name="RETURN"></a><h2 class="nroffsh">RETURN VALUE</h2>
93 <p class="level0">Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or CURLE_OUT_OF_MEMORY if there was insufficient heap space. <a name="SEE"></a><h2 class="nroffsh">SEE ALSO</h2>
94 <p class="level0"><a Class="manpage" href="./CURLOPT_SSL_VERIFYPEER.html">CURLOPT_SSL_VERIFYPEER</a>, <span Class="manpage"> </span> <a Class="manpage" href="./CURLOPT_SSL_VERIFYHOST.html">CURLOPT_SSL_VERIFYHOST</a>, <span Class="manpage"> </span> <a Class="manpage" href="./CURLOPT_CAINFO.html">CURLOPT_CAINFO</a>, <span Class="manpage"> </span> <a Class="manpage" href="./CURLOPT_CAPATH.html">CURLOPT_CAPATH</a>, <span Class="manpage"> </span> <p class="roffit">
95  This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.
96 </body></html>