title: curl command line ssl session reuse
body: <p>session reuse in ssl is quite common and curl is widely used also in command line. It surely should have an option to save a SSL/TLS session id to a file and then reuse it on the next call...</p>
  
  <p>Using curl in areas where mobile transfers are not cheap this is kind of a must.</p>
  
  <p>Does anyone know of any possiblity to implement this or it maybe is already somewhere available?</p>
  
  <p>In openssl this isn't to hard (read or store session to file )</p>
  
  <pre><code>Setting session from previous attempt:
  SSL_SESSION* session = d2i_SSL_SESSION(NULL, &amp;readFromFile,fileLen);
  SSL_set_session(cSSL, session );
  SSL_SESSION_free(cachedSession);
  
  Storing session from current connection:
  SSL_SESSION* session = SSL_get1_session(cSSL)
  int len = i2d_SSL_SESSION(session, NULL); //get needed size
  unsigned char *file_data = new char[len]
  len = i2d_SSL_SESSION(session, &amp;file_data );
  //Store to file file_data of len
  </code></pre>
  
  <p>For crude command line operation you do not need to store host and port, to know to which host the session belongs, but let user take care of it.</p>
  
  <p>So curl would come with 1 or maybe 2 flags</p>
  
  <pre><code>--ssl-session-file @file
  </code></pre>
  
  <p>or</p>
  
  <pre><code>--ssl-session-file @existing_session_file and --ssl-session-save-file @new_session_file
  </code></pre>
  
  <p>Can this be done ?
  This would make commandline curl and libcurl even more useful in limited mobile networks...</p>
  
  <p>Is this possible to add?</p>
  
  <p>With kind regards,</p>