1<refentry id="refsslcertio"> 2 3 <refmeta> 4 <refentrytitle>ne_ssl_cert_read</refentrytitle> 5 <manvolnum>3</manvolnum> 6 </refmeta> 7 8 <refnamediv> 9 <refname id="ne_ssl_cert_read">ne_ssl_cert_read</refname> 10 <refname id="ne_ssl_cert_write">ne_ssl_cert_write</refname> 11 <refname id="ne_ssl_cert_import">ne_ssl_cert_import</refname> 12 <refname id="ne_ssl_cert_export">ne_ssl_cert_export</refname> 13 <refpurpose>functions to read or write certificates to and from files or strings</refpurpose> 14 </refnamediv> 15 16 <refsynopsisdiv> 17 18 <funcsynopsis> 19 20 <funcsynopsisinfo>#include <ne_ssl.h></funcsynopsisinfo> 21 22 <funcprototype> 23 <funcdef>ne_ssl_certificate *<function>ne_ssl_cert_read</function></funcdef> 24 <paramdef>const char *<parameter>filename</parameter></paramdef> 25 </funcprototype> 26 27 <funcprototype> 28 <funcdef>int <function>ne_ssl_cert_write</function></funcdef> 29 <paramdef>const ne_ssl_certificate *<parameter>cert</parameter></paramdef> 30 <paramdef>const char *<parameter>filename</parameter></paramdef> 31 </funcprototype> 32 33 <funcprototype> 34 <funcdef>ne_ssl_certificate *<function>ne_ssl_cert_import</function></funcdef> 35 <paramdef>const char *<parameter>data</parameter></paramdef> 36 </funcprototype> 37 38 <funcprototype> 39 <funcdef>char *<function>ne_ssl_cert_export</function></funcdef> 40 <paramdef>const ne_ssl_certificate *<parameter>cert</parameter></paramdef> 41 </funcprototype> 42 43 </funcsynopsis> 44 45 </refsynopsisdiv> 46 47 <refsect1> 48 <title>Description</title> 49 50 <para>The <function>ne_ssl_cert_write</function> function writes a 51 certificate to a file using the PEM encoding. The 52 <function>ne_ssl_cert_export</function> function returns a 53 base64-encoded &nul;-terminated string representing the 54 certificate. This string is malloc-allocated and should be 55 destroyed using <function>free</function> by the caller.</para> 56 57 <para>The <function>ne_ssl_cert_read</function> function reads a 58 certificate from a PEM-encoded file, and returns a certificate 59 object. The <function>ne_ssl_cert_import</function> function 60 returns a certificate object from a base64-encoded string, 61 <parameter>data</parameter>, as returned by 62 <function>ne_ssl_cert_export</function>. The certificate object 63 returned by these functions should be destroyed using <xref 64 linkend="ne_ssl_cert_free"/> after use.</para> 65 66 67 </refsect1> 68 69 <refsect1> 70 <title>Return value</title> 71 72 <para><function>ne_ssl_cert_read</function> returns &null; if a 73 certificate could not be read from the file. 74 <function>ne_ssl_cert_write</function> returns non-zero if the 75 certificate could not be written to the file. 76 <function>ne_ssl_cert_export</function> always returns a 77 &nul;-terminated string, and never &null;. 78 <function>ne_ssl_cert_import</function> returns &null; if the 79 string was not a valid base64-encoded certificate.</para> 80 81 </refsect1> 82 83 <refsect1> 84 <title>Encoding Formats</title> 85 86 <para>The string produced by 87 <function>ne_ssl_cert_export</function> is the base64 encoding of 88 the DER representation of the certificate. The file written by 89 <function>ne_ssl_cert_write</function> uses the PEM format: this 90 is the base64 encoding of the DER representation with newlines 91 every 64 characters, and start and end marker lines.</para> 92 </refsect1> 93 94</refentry> 95 96