bio_do_connect() returns -1

微笑、不失礼 提交于 2019-12-13 07:08:37

问题


I'm trying to program a server/client application like the figure below.

The issueTicket.cgi is an executable file written in C. My colleague setup the apache and programmed the issueTicket.cgi, and I can access the issueTicket.cgi by typing http://[ubuntuIP]/cgi-bin/SEC_IssueTicket.cgi in my browser.

The problem lies in the client side. I have to program a askTicket.exe on windows using Openssl, and BIO_do_connect() always returns -1. The following is my code.

SSL_load_error_strings();
ERR_load_BIO_strings();
SSL_library_init();     /* Return value is always 1 */
OpenSSL_add_all_algorithms();
...
*sslCtx = SSL_CTX_new(TLSv1_1_client_method());
sslRet = SSL_CTX_load_verify_locations(*sslCtx, (const char *)certpath, NULL);
*sbio = BIO_new_ssl_connect(*sslCtx);
BIO_set_conn_hostname(*sbio, "[ubuntuIP]:80/cgi-bin/issueTicket.cgi");
BIO_set_nbio(*sbio, 1);
BIO_get_ssl(*sbio, &ssl);
SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
BIO_do_connect(*sbio) // always return -1

Can anyone tell where my problem is?

来源:https://stackoverflow.com/questions/38301089/bio-do-connect-returns-1

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