curl command line ssl session reuse

試著忘記壹切 提交于 2019-12-22 10:57:47

问题


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,

来源:https://stackoverflow.com/questions/38857881/curl-command-line-ssl-session-reuse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!