C语言实现https请求, 先贴上代码, 以下代码来自<>, 稍作修改
https_client.c
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
void main(int argc, char **argv)
{
SSL *ssl = NULL;
SSL_CTX *ctx = NULL;
const SSL_METHOD *client_method;
X509 *server_cert;
int sd,err;
char *str,*hostname,outbuf[4096],inbuf[4096],host_header[512];
struct hostent *host_entry;
struct sockaddr_in server_socket_address;
struct in_addr ip;
/* (1) 初始化openssl库 */
SSL_library_init();
ERR_load_crypto_strings();
SSL_load_error_strings();
OpenSSL_add_all_algorithms();
client_method = SSLv23_client_method( );