diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 2f2aae1e7335b..8a987aab8c0dd 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -1872,8 +1872,7 @@ PHP_FUNCTION(openssl_x509_export) } if (!notext && !X509_print(bio_out, cert)) { php_openssl_store_errors(); - } - if (PEM_write_bio_X509(bio_out, cert)) { + } else if (PEM_write_bio_X509(bio_out, cert)) { BUF_MEM *bio_buf; BIO_get_mem_ptr(bio_out, &bio_buf);