S
S
Sergey Savostin2020-02-27 13:26:42
OpenSSL
Sergey Savostin, 2020-02-27 13:26:42

OpenSSL client via prosky. Is there an example?

I have already climbed "the whole Internet" ™ - for the life of me I can not find an example of an https client on a "pure" OpenSSL lib on c (++) through an http (s?) proxy.
As I understand it, first connect goes to the proxy itself (without SSL?), then "CONNECT realhost.com:443" is sent to it and already to it with SSL. So? Are there http proxies that can encrypt traffic to them? Or is it not needed?
Because:

> curl https://ipinfo.io/ -v -x http://54.37.130.2:3128
<показывает ip>
> curl https://ipinfo.io/ -v -x https://54.37.130.2:3128
* OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection

Schematically, I have this:
SSL_library_init();
OPENSSL_init_ssl(0, NULL);
OpenSSL_add_all_algorithms();
SSL_load_error_strings();
ERR_load_crypto_strings();
ERR_load_BIO_strings();
SSL_CTX* ctx = SSL_CTX_new(SSLv23_method());
SSL_CTX_set_options(ctx, SSL_OP_ALL);

SSL* ssl;
BIO* bio = BIO_new_ssl_connect(ctx);
BIO_get_ssl(bio, &ssl);
SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
BIO_set_conn_hostname(bio, proxy_ip);
BIO_set_conn_port(bio, proxy_port);
SSL_set_tlsext_host_name(ssl, (void*)proxy_ip)); // надо ли?
BIO_do_connect(bio); // <--------------- error 0 ибо прокси, как я понимаю, ждёт plain, а не ssl
char buffer = "CONNECT realhost.com:443 HTTP/1.1\r\nProxy-Connection: Keep-Alive\r\n\r\n");
BIO_write(bio, buffer, strlen(buffer));
// <--------- что дальше?

If you put "realhost.com" instead of proxy_ip, and "443" instead of proxy_port, then everything works (i.e. directly without a proxy).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2020-02-27
@ky0

Obviously, because the certificate is invalid according to the IP address.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question