Revert "Imported Upstream version 7.44.0"
[platform/upstream/curl.git] / docs / libcurl / opts / CURLOPT_SSH_KEYFUNCTION.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_SSH_KEYFUNCTION man page</title>
5 <meta name="generator" content="roffit">
6 <STYLE type="text/css">
7 P.level0 {
8  padding-left: 2em;
9 }
10
11 P.level1 {
12  padding-left: 4em;
13 }
14
15 P.level2 {
16  padding-left: 6em;
17 }
18
19 span.emphasis {
20  font-style: italic;
21 }
22
23 span.bold {
24  font-weight: bold;
25 }
26
27 span.manpage {
28  font-weight: bold;
29 }
30
31 h2.nroffsh {
32  background-color: #e0e0e0;
33 }
34
35 span.nroffip {
36  font-weight: bold;
37  font-size: 120%;
38  font-family: monospace;
39 }
40
41 p.roffit {
42  text-align: center;
43  font-size: 80%;
44 }
45 </STYLE>
46 </head><body>
47
48 <p class="level0"><a name="NAME"></a><h2 class="nroffsh">NAME</h2>
49 <p class="level0">CURLOPT_SSH_KEYFUNCTION - callback for known host matching logic <a name="SYNOPSIS"></a><h2 class="nroffsh">SYNOPSIS</h2>
50 <p class="level0"><pre>
51 <p class="level0">#include &lt;curl/curl.h&gt;
52  <p class="level0">enum curl_khstat {
53  &nbsp; CURLKHSTAT_FINE_ADD_TO_FILE,
54  &nbsp; CURLKHSTAT_FINE,
55  &nbsp; CURLKHSTAT_REJECT, /* reject the connection, return an error */
56  &nbsp; CURLKHSTAT_DEFER,  /* do not accept it, but we can't answer right
57  &nbsp;                       now so this causes a CURLE_DEFER error but
58  &nbsp;                       otherwise the connection will be left intact
59  &nbsp;                       etc */
60  };
61  <p class="level0">enum curl_khmatch {
62  &nbsp; CURLKHMATCH_OK,       /* match */
63  &nbsp; CURLKHMATCH_MISMATCH, /* host found, key mismatch! */
64  &nbsp; CURLKHMATCH_MISSING,  /* no matching host/key found */
65  };
66  <p class="level0">struct curl_khkey {
67  &nbsp; const char *key; /* points to a zero-terminated string encoded with
68  &nbsp;                     base64 if len is zero, otherwise to the "raw"
69  &nbsp;                     data */
70  &nbsp; size_t len;
71  &nbsp; enum curl_khtype keytype;
72  };
73  <p class="level0">int ssh_keycallback(CURL *easy,
74  &nbsp;                   const struct curl_khkey *knownkey,
75  &nbsp;                   const struct curl_khkey *foundkey,
76  &nbsp;                   enum curl_khmatch,
77  &nbsp;                   void *clientp);
78  <p class="level0">CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_KEYFUNCTION,
79  &nbsp;                         ssh_keycallback);
80  </pre>
81 <a name="DESCRIPTION"></a><h2 class="nroffsh">DESCRIPTION</h2>
82 <p class="level0">Pass a pointer to your callback function, which should match the prototype shown above. 
83 <p class="level0">It gets called when the known_host matching has been done, to allow the application to act and decide for libcurl how to proceed. The callback will only be called if <a Class="emphasis" href="./CURLOPT_SSH_KNOWNHOSTS.html">CURLOPT_SSH_KNOWNHOSTS</a> is also set. 
84 <p class="level0">This callback function gets passed the CURL handle, the key from the known_hosts file <span Class="emphasis">knownkey</span>, the key from the remote site <span Class="emphasis">foundkey</span>, info from libcurl on the matching status and a custom pointer (set with <a Class="emphasis" href="./CURLOPT_SSH_KEYDATA.html">CURLOPT_SSH_KEYDATA</a>). It MUST return one of the following return codes to tell libcurl how to act: 
85 <p class="level0">
86 <p class="level0"><a name="CURLKHSTATFINEADDTOFILE"></a><span class="nroffip">CURLKHSTAT_FINE_ADD_TO_FILE</span> 
87 <p class="level1">The host+key is accepted and libcurl will append it to the known_hosts file before continuing with the connection. This will also add the host+key combo to the known_host pool kept in memory if it wasn't already present there. The adding of data to the file is done by completely replacing the file with a new copy, so the permissions of the file must allow this. 
88 <p class="level0"><a name="CURLKHSTATFINE"></a><span class="nroffip">CURLKHSTAT_FINE</span> 
89 <p class="level1">The host+key is accepted libcurl will continue with the connection. This will also add the host+key combo to the known_host pool kept in memory if it wasn't already present there. 
90 <p class="level0"><a name="CURLKHSTATREJECT"></a><span class="nroffip">CURLKHSTAT_REJECT</span> 
91 <p class="level1">The host+key is rejected. libcurl will deny the connection to continue and it will be closed. 
92 <p class="level0"><a name="CURLKHSTATDEFER"></a><span class="nroffip">CURLKHSTAT_DEFER</span> 
93 <p class="level1">The host+key is rejected, but the SSH connection is asked to be kept alive. This feature could be used when the app wants to somehow return back and act on the host+key situation and then retry without needing the overhead of setting it up from scratch again. <a name="DEFAULT"></a><h2 class="nroffsh">DEFAULT</h2>
94 <p class="level0">NULL <a name="PROTOCOLS"></a><h2 class="nroffsh">PROTOCOLS</h2>
95 <p class="level0">SFTP and SCP <a name="EXAMPLE"></a><h2 class="nroffsh">EXAMPLE</h2>
96 <p class="level0">TODO <a name="AVAILABILITY"></a><h2 class="nroffsh">AVAILABILITY</h2>
97 <p class="level0">Added in 7.19.6 <a name="RETURN"></a><h2 class="nroffsh">RETURN VALUE</h2>
98 <p class="level0">Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. <a name="SEE"></a><h2 class="nroffsh">SEE ALSO</h2>
99 <p class="level0"><a Class="manpage" href="./CURLOPT_SSH_KEYDATA.html">CURLOPT_SSH_KEYDATA</a>, <a Class="manpage" href="./CURLOPT_SSH_KNOWNHOSTS.html">CURLOPT_SSH_KNOWNHOSTS</a>, <span Class="manpage"> </span> <p class="roffit">
100  This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.
101 </body></html>