NE_SSL_CERT_READ(3)

πŸ’… NE_SSL_CERT_READ(3) β€” neon API reference, bestie edition πŸŽ€

okay so this page lives in the neon API reference and it's literally all about the four functions that read and write certificates to and from files or strings. it's giving "glow up for your TLS creds" ✨


🌸 NAME 🌸

ne_ssl_cert_read, ne_ssl_cert_write, ne_ssl_cert_import, ne_ssl_cert_export β€” functions to read or write certificates to and from files or strings 🫢


✨ SYNOPSIS ✨

#include <ne_ssl.h>

ne_ssl_certificate *ne_ssl_cert_read(const char *filename);

int ne_ssl_cert_write(const ne_ssl_certificate *cert,
                      const char *filename);

ne_ssl_certificate *ne_ssl_cert_import(const char *data);

char *ne_ssl_cert_export(const ne_ssl_certificate *cert);

like, four functions, four vibes, all iconic πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so first up: ne_ssl_cert_write writes a certificate to a file using the PEM encoding. that's it, that's the whole job, and it does it well πŸ‘‘

then ne_ssl_cert_export returns a base64-encoded NUL-terminated string representing the certificate. and listen β€” this string is malloc-allocated, so you, the caller, have to destroy it using free. no cap. don't just leave it lying around, that's not the vibe πŸ’€

now the reading side, bestie:

  • ne_ssl_cert_read reads a certificate from a PEM-encoded file, and returns a certificate object. simple, clean, slays 🌈
  • ne_ssl_cert_import returns a certificate object from a base64-encoded string, data, exactly as returned by ne_ssl_cert_export. they're literally soulmates 🫢
⚠️ and here's the thing: the certificate object returned by these functions should be destroyed using ne_ssl_cert_free(3) after use. yes, that's a SEE ALSO moment, we love a cross-reference. clean up after yourself, periodt πŸ’–

πŸ”₯ RETURN VALUE πŸ”₯

  • ne_ssl_cert_read returns NULL if a certificate could not be read from the file 😭
  • ne_ssl_cert_write returns non-zero if the certificate could not be written to the file 😭
  • ne_ssl_cert_export always returns a NUL-terminated string, and never NULL. the way that function has never once let you down, we stan a reliable queen πŸ‘‘
  • ne_ssl_cert_import returns NULL if the string was not a valid base64-encoded certificate. rude, but fair πŸ™ˆ

πŸŽ€ ENCODING FORMATS πŸŽ€

so the string produced by ne_ssl_cert_export is the base64 encoding of the DER representation of the certificate. hyperspecific, we know ✨

and the file written by ne_ssl_cert_write uses the PEM format β€” which is:

  1. the base64 encoding of the DER representation
  2. with newlines every 64 characters
  3. plus start and end marker lines

that's it, that's the whole recipe, it's giving grandma's secret formula but make it cryptography πŸ“


Copyright Β© 2001-2026 Joe Orton


and that's the whole page, bestie β€” no cap, you're now certified fluent in certificate I/O πŸ’…βœ¨

πŸ’– written with love, delivered with neon, dated 03/20/2026 β€” go forth and read/write those certs, queen πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from