PEM_BYTES_READ_BIO(3)

NAME
PEM_bytes_read_bio - read a PEM-encoded data structure from a BIO

SYNOPSIS
#include <openssl/pem.h>
int
PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp, pem_password_cb *cb, void *u);

DESCRIPTION
PEM_bytes_read_bio() reads PEM-formatted (RFC 1421) data from the BIO bp for the data type given in name (RSA PRIVATE KEY, CERTIFICATE, etc.). If multiple PEM-encoded data structures are present in the same stream, PEM_bytes_read_bio() will skip non-matching data types and continue reading. Non-PEM data present in the stream may cause an error.

The PEM header may indicate that the following data is encrypted; if so, the data will be decrypted, waiting on user input to supply a passphrase if needed. The password callback cb and rock u are used to obtain the decryption passphrase, if applicable.

Some data types have compatibility aliases, such as a file containing X509 CERTIFICATE matching a request for the deprecated type CERTIFICATE. The actual type indicated by the file is returned in *pnm if pnm is non-NULL. The caller must free the storage pointed to by *pnm.

The returned data is the DER-encoded form of the requested type, in *pdata with length *plen. The caller must free the storage pointed to by *pdata.

RETURN VALUES
PEM_bytes_read_bio() returns 1 for success or 0 for failure.

SEE ALSO
PEM_read(3), PEM_read_bio_PrivateKey(3)

HISTORY
PEM_bytes_read_bio() first appeared in OpenSSL 0.9.7 and has been available since OpenBSD 3.2.