X509_LOAD_HTTP(3ossl)

πŸ’– X509_LOAD_HTTP πŸ’– (the 3ossl one, from the OpenSSL besties)

okay so bestie, pull up a chair, because today we're talking about loading certificates and CRLs over HTTP and honestly?? it's giving network goblin energy in the best way possible. πŸ¦‹


✨ NAME ✨

X509_load_http, X509_http_nbio, X509_CRL_load_http, X509_CRL_http_nbio β€” certificate and CRL loading functions. literally just the "go fetch me a cert / a revocation list off the internet" squad. 🌈


πŸŽ€ SYNOPSIS πŸŽ€

first things first, you gotta include the header, no cap:

#include <openssl/x509.h>

X509 *X509_load_http(const char *url, BIO *bio, BIO *rbio, int timeout);
X509_CRL *X509_CRL_load_http(const char *url, BIO *bio, BIO *rbio, int timeout);

and now the tea β˜• β€” these next two macros have been deprecated since OpenSSL 3.0, and you can hide them entirely by defining OPENSSL_API_COMPAT with a suitable version value, see openssl_user_macros(7):

#define X509_http_nbio(rctx, pcert)
#define X509_CRL_http_nbio(rctx, pcrl)
heads up bestie: deprecated means old money, don't build new stuff on it. they still work, they're just not the main character anymore. πŸ’…

🌸 DESCRIPTION 🌸

X509_load_http() and X509_CRL_load_http() load a certificate or a CRL, respectively, in ASN.1 format using HTTP from the given url. that's it, that's the vibe. 🫢

size limits, because we respect boundaries: maximum size of the HTTP response is 100 kB for certificates and 32 MB for CRLs, and both of those are hard coded in the functions. not configurable, not vibes-based, just fixed. πŸ’€

BIO situation, and it's lowkey flexible:

  • if bio is given and rbio is NULL, then this BIO is used instead of an internal one for connecting, writing the request, and reading the response.
  • if both bio and rbio are given (which may be memory BIOs, for instance), then no explicit connection is attempted, bio is used for writing the request, and rbio for reading the response. slay, fully custom pipeline. 🧚

timeout deets, memorize this:

  • timeout > 0 β†’ that's the maximum number of seconds to wait until the transfer is complete.
  • timeout = 0 β†’ enables waiting indefinitely. iconic patience. 🧘
  • timeout < 0 β†’ immediately leads to a timeout condition. not me setting a negative timeout and then acting surprised 😭

and last but not least, X509_http_nbio() and X509_CRL_http_nbio() are macros for backward compatibility that have the same effect as the functions above but with infinite timeout and without the possibility to specify custom BIOs. so, less control, but zero setup. take it or leave it. 🌈


πŸ‘‘ RETURN VALUES πŸ‘‘

on success the function yields the loaded value, else NULL. that's the whole mood. ✨

error conditions include connection/transfer timeout, parse errors, etc. so if you get a NULL back, something went sideways and you should check your URL, your network, and your life choices. πŸ“


πŸ’œ SEE ALSO πŸ’œ

  • OSSL_HTTP_get(3) β€” the sibling that knows things too. go read it, fr fr. πŸ“–

⭐ HISTORY ⭐

  • X509_load_http() and X509_CRL_load_http() were added in OpenSSL 3.0.
  • X509_http_nbio() and X509_CRL_http_nbio() were deprecated in OpenSSL 3.0.

so they were born and retired in the same era, which is honestly kind of a moment. πŸŽ€


Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


okay bestie that's the whole page, go forth and load your certs responsibly. this was OpenSSL 3.5.9, dated 2026-09-29, page X509_LOAD_HTTP(3ossl) β€” mwah, ily, bye! πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from