libressl/portable

UNABLE to send an SSL/HTTPS request

Closed this issue · 2 comments

on this example :

#include "libressl/include/tls.h"

#define BUF_SIZ 4096

int
main (void)
{

    char request[BUF_SIZ] = "GET / HTTP/1.1\r\nHost: google.com\r\nConnection: Close\r\n\r\n";

    struct tls_config *config;
    struct tls *ctx;
    config = tls_config_new();

    //tls_config_insecure_noverifycert(config);
    //tls_config_insecure_noverifyname(config);
    //tls_config_insecure_noverifytime(config);

    ctx = tls_client();
    tls_configure(ctx, config);

    tls_connect(ctx, "google.com", "443");
    // Writes to the encrypted socket aka send the request
    tls_write(ctx, request, BUF_SIZ);
    // Cleanup
    tls_close(ctx);
    tls_free(ctx);
    return 0;
}

what should i configure to be able to receive the req ?

You would need to call tls_read() to read the response and then process it as necessary.

I also suggest reading the man page and implementing appropriate error checking and retries for tls_read() and tls_write(), at a minimum.