---
name: "ne_ssl_cert_read"
section: "3"
platform: "linux"
package: "neon"
version: "0.37.1-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/ne_ssl_cert_read"
---

# ne\_ssl\_cert\_read(3)

functions to read or write certificates to and from files or strings

## 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***);**

## DESCRIPTION

The **ne\_ssl\_cert\_write** function writes a certificate to a file using the PEM encoding. The **ne\_ssl\_cert\_export** function returns a base64-encoded NUL-terminated string representing the certificate. This string is malloc-allocated and should be destroyed using **free** by the caller.

The **ne\_ssl\_cert\_read** function reads a certificate from a PEM-encoded file, and returns a certificate object. The **ne\_ssl\_cert\_import** function returns a certificate object from a base64-encoded string, *data*, as returned by **ne\_ssl\_cert\_export**. The certificate object returned by these functions should be destroyed using [**ne\_ssl\_cert\_free**(3)](/ne_ssl_cert_free/3.md) after use.

## 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. **ne\_ssl\_cert\_import** returns NULL if the string was not a valid base64-encoded certificate.

## ENCODING FORMATS

The string produced by **ne\_ssl\_cert\_export** is the base64 encoding of the DER representation of the certificate. The file written by **ne\_ssl\_cert\_write** uses the PEM format: this is the base64 encoding of the DER representation with newlines every 64 characters, and start and end marker lines.

## COPYRIGHT

Copyright © 2001-2026 Joe Orton\
