使用BIO开发https客户端的问题
我的代码大致如下:
BIO *bio;
SSL_CTX *ctx ;
SSL * ssl;
SSL_library_init();
SSL_load_error_strings();
ERR_load_BIO_strings();
OpenSSL_add_all_algorithms();
const SSL_METHOD *meth=SSLv3_client_method();
ctx= SSL_CTX_new(meth);
bio = BIO_new_ssl_connect(ctx);
BIO_set_conn_hostname(bio, "127.0.0.1:https");
BIO_do_accept(bio);
std:string szContent="name=admin&password=";
char tmp[128];
sprintf(tmp,"Content-Length: %d\r\n",szContent.size());
szHead+="POST /api/Query.action HTTP/1.0\r\n";
szHead+="Host: query.unionpaysecure.com\r\n";
szHead+="Content-Type: text/plain;charset=UTF-8\r\n";
szHead+=tmp;
szHead+="Connection: close\r\n";
szHead+="\r\n";
szHead+=szContent;
IO_write(bio,szHead.c_str(),szHead.size());
char msg[1025];
for(;;)
{
memset(msg,0,1025);
int nRet=BIO_read(bio,msg,1024);
if(nRet<=0){
break;
}else{
printf(msg);
szContent+=msg;
}
}
SSL_CTX_free(ctx);
BIO_free_all(bio);
-----------------------------------
服务器端没有收到POST的内容(name和password)或者说post环境的内容是空的
不知道哪里出问题了