#1, #2: libressl doesn't yet have sk_new_reserve. #3: This check doesn't make sense for EC keys. (Also it ignores the default key size compiled into libcrypto, only looks at default_bits in openssl.cnf and any settings in the php file, which results in bogus failures). Index: ext/openssl/openssl.c --- ext/openssl/openssl.c.orig +++ ext/openssl/openssl.c @@ -2308,7 +2308,7 @@ static STACK_OF(X509) *php_openssl_load_all_certs_from goto end; } - if(!(stack = sk_X509_new_reserve(NULL, sk_X509_INFO_num(sk)))) { + if(!(stack = sk_X509_new_null())) { php_openssl_store_errors(); goto end; } @@ -2317,7 +2317,11 @@ static STACK_OF(X509) *php_openssl_load_all_certs_from while (sk_X509_INFO_num(sk)) { xi=sk_X509_INFO_shift(sk); if (xi->x509 != NULL) { - sk_X509_push(stack,xi->x509); + if(sk_X509_push(stack,xi->x509) == 0) { + php_error_docref(NULL, E_ERROR, "Memory allocation failure"); + sk_X509_pop_free(stack,X509_free); + goto end; + } xi->x509=NULL; } X509_INFO_free(xi);