BIO *bo; if(sec && !publicOnly) { bo = BIO_new(BIO_s_mem()); PEM_write_bio_RSAPrivateKey(bo, sec, NULL, NULL, 0, NULL, NULL); } else if(pub) { bo = BIO_new(BIO_s_mem()); PEM_write_bio_RSAPublicKey(bo, pub); } else { *out = 0; *outlen = 0; return; }
BIO *bo = BIO_new(BIO_s_mem()); PEM_write_bio_X509(bo, x);
	void toPEM(char **out, unsigned int *outlen, bool publicOnly)	{		BIO *bo;		if(sec && !publicOnly) {			bo = BIO_new(BIO_s_mem());			PEM_write_bio_RSAPrivateKey(bo, sec, NULL, NULL, 0, NULL, NULL);		}		else if(pub) {			bo = BIO_new(BIO_s_mem());			PEM_write_bio_RSAPublicKey(bo, pub);		}		else {			*out = 0;			*outlen = 0;			return;		}		*out = bio2buf(bo, outlen);	}