curl command line ssl session reuse

2019-05-10 16:37发布

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...

Using curl in areas where mobile transfers are not cheap this is kind of a must.

Does anyone know of any possiblity to implement this or it maybe is already somewhere available?

In openssl this isn't to hard (read or store session to file )

Setting session from previous attempt:
SSL_SESSION* session = d2i_SSL_SESSION(NULL, &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, &file_data );
//Store to file file_data of len

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.

So curl would come with 1 or maybe 2 flags

--ssl-session-file @file

or

--ssl-session-file @existing_session_file and --ssl-session-save-file @new_session_file

Can this be done ? This would make commandline curl and libcurl even more useful in limited mobile networks...

Is this possible to add?

With kind regards,

0条回答
登录 后发表回答