<html><head></head><body><div>Hi again Beni,</div><div><span></span></div><div><br></div><div>On Wed, 2022-06-22 at 08:29 +0200, Benedikt Hallinger wrote:</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>Hi David and thank you for your advice and example.<br></div></blockquote><div><br></div><div>my pleasure.<br>I was about to send a slightly improved version of my example code<br>regarding the use of proxies and the expected content type - see attached<br>and an extended sample invocation (of course, adapt "myproxy" as needed):</div><div><br></div><pre style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-variant-caps: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4); -webkit-text-stroke-width: 0px; text-decoration: none;">https_proxy=myproxy ./http_client <a href="https://example.com">https://example.com</a> && echo ok</pre><div><br></div><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>I tried to compile it, run onto errors tough.<br></div><div>I just put the file into my openssl source tree, which is on commit:<br></div><div>commit 9e86b3815719d29f7bde2294403f97c42ce82a16 (HEAD, <br></div><div>origin/openssl-3.0)<br></div></blockquote><div><br></div><div>I've just tried myself using that commit (and default configuration)<br>and as expected everything works fine.<br></div><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>$ gcc http_client.c -Iinclude -L. -lcrypto -lssl -o http_client<br></div><div>/usr/bin/ld: ./libssl.a(libssl-lib-ssl_cert.o): in function <br></div><div>`add_uris_recursive':<br></div><div>ssl_cert.c:(.text+0x116): undefined reference to `OSSL_STORE_open'<br></div><div>/usr/bin/ld: ssl_cert.c:(.text+0x134): undefined reference to <br></div><div>`OSSL_STORE_eof'<br></div><div>[...]</div></blockquote><div><br></div><div>This issue is pretty surely unrelated to the example code itself<br>but most likely due to some general build issue you have, such as some inconsistency with pre-installed OpenSSL versions.<br>Sorry that I do not have the time to provide further aid on such general build issues.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>David</div><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><br></div><div>Am 2022-06-21 22:52, schrieb David von Oheimb:<br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>Hallo Beni,<br></div><div><br></div><div>good that you ask.<br></div><div><br></div><div>Using the new HTTP client API with TLS (possibly via a proxy) indeed<br></div><div>is not easy so far.<br></div><div>I'm going to improve this by adding some high-level helper functions<br></div><div>and extending the docs.<br></div><div><br></div><div>A good starting point when looking for examples is, as usual, the<br></div><div>application code in apps/.<br></div><div>In this case, there is some pretty useful code in apps/lib/apps.c,<br></div><div>but it turns out that the adaptation of app_http_get_asn1() and<br></div><div>app_http_tls_cb()<br></div><div><br></div><div>for receiving plain text (rather than ASN.1 encoded data) from the<br></div><div>server<br></div><div>is not straightforward because OSSL_HTTP_get() may close the SSL read<br></div><div>BIO prematurely.<br></div><div>Also the behavior of non-blocking BIOs makes things a little more<br></div><div>tricky than expected.<br></div><div>Meanwhile I got it working - see the example attached.<br></div><div><br></div><div>Example build and usage:<br></div><div><br></div><div>gcc http_client.c -Iinclude -L. -lcrypto -lssl -o http_client<br></div><div><br></div><div>./http_client <a href="https://httpbin.org/">https://httpbin.org/</a> && echo ok<br></div><div><br></div><div>Regards,<br></div><div> David<br></div><div><br></div><div>On 20.06.22 10:54, Benedikt Hallinger wrote:<br></div><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>Hi there,<br></div><div>I currently try to get my hands dirty with C++ and  the new HTTPs<br></div><div>client<br></div><div>introduced with OpenSSL 3.<br></div><div>However I struggle to get started. My goal is to open a https<br></div><div>secured<br></div><div>website and download its contents into a std::string for further<br></div><div>parsing.<br></div><div><br></div><div>Does someone on the list know of a small basic example?<br></div><div>I imagine that I'm not the first person implementing a HTTPs website<br></div><div><br></div><div>connector with OpenSSL 3.<br></div><div><br></div><div>Thank you for your support,<br></div><div>Beni<br></div></blockquote></blockquote><div><br></div></blockquote></body></html>