NOTES:
Here's exactly what I did from start to finish in order to build a simple HTTPS client using openssl and Borland C++ Builder. Installing openssl is documented in INSTALL.W32, included in the source distribution, but I've documented my experience here.....
| #include
<openssl/crypto.h> #include <openssl/x509.h> #include <openssl/pem.h> #include <openssl/ssl.h> #include <openssl/err.h> |
SOCKET sock;
// build regular SOCK_STREAM sock and connect to server
// ... (I'm not going into these details)
// pretend sock is now connected....
// here's the data items we'll use....
char buf[1000];
char request[1000];
SSL_CTX *ctx;
SSL *ssl;
int err;
// initialize SSL stuff
//
SSL_load_error_strings();
SSL_library_init();
// build the SSL objects...
//
ctx=SSL_CTX_new(SSLv2_client_method());
ssl=SSL_new(ctx);
// assign the socket you created for SSL to use
//
SSL_set_fd(ssl, sock);
// communicate!!
/////////////////////////////////////////////
err=SSL_connect(ssl);
sprintf(request,
"GET %s HTTP/1.0\r\nHost: %s\r\n\r\n","/" ,
"www.theserver.com");
err=SSL_write(ssl, request, strlen(request));
while(1)
{
int read_size;
read_size=SSL_read(ssl, buf, sizeof(buf)-1);
buf[read_size]='\0';
if(read_size > 0)
{
// I'm assuming you have a Memo object
|