The X509 encode and decode routines encode and parse an
X509 structure, which represents an X509 certificate.d2i_X509() attempts to decode len bytes at *in. If successful a pointer to the X509 structure is returned. If an error occurred then NULL is returned. If px is not NULL then the returned structure is written to *px. If *px is not NULL then it is assumed that *px contains a valid X509 structure and an attempt is made to reuse it. If the call is successful *in is incremented to the byte following the parsed data.
i2d_X509() encodes the structure pointed to by x into DER format. If out is not NULL is writes the DER encoded data to the buffer at *out, and increments it to point after the data just written. If the return value is negative an error occurred, otherwise it returns the length of the encoded data.
For OpenSSL 0.9.7 and later if *out is NULL memory will be allocated for a buffer and the encoded data written to it. In this case *out is not incremented and it points to the start of the data just written.
d2i_X509_bio() is similar to d2i_X509() except it attempts to parse data from BIO bp.
d2i_X509_fp() is similar to d2i_X509() except it attempts to parse data from FILE pointer fp.
i2d_X509_bio() is similar to i2d_X509() except it writes the encoding of the structure x to BIO bp and it returns 1 for success and 0 for failure.
i2d_X509_fp() is similar to i2d_X509() except it writes the encoding of the structure x to BIO bp and it returns 1 for success and 0 for failure.