问题
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