Skip to content

Commit 2ef8809

Browse files
committed
Make openssl_error_string test work in OpenSSL 1.1.1
It was the only failing test
1 parent 9090a21 commit 2ef8809

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

ext/openssl/tests/openssl_error_string_basic.phpt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,17 @@ while (($enc_error_new = openssl_error_string()) !== false) {
7979
var_dump($error_queue_size);
8080
echo "\n";
8181

82+
$is_111 = OPENSSL_VERSION_NUMBER >= 0x10101000;
83+
$err_pem_no_start_line = $is_111 ? '0909006C': '0906D06C';
84+
8285
// PKEY
8386
echo "PKEY errors\n";
8487
// file for pkey (file:///) fails when opennig (BIO_new_file)
8588
@openssl_pkey_export_to_file("file://" . $invalid_file_for_read, $output_file);
8689
expect_openssl_errors('openssl_pkey_export_to_file opening', ['02001002', '2006D080']);
8790
// file or private pkey is not correct PEM - failing PEM_read_bio_PrivateKey
8891
@openssl_pkey_export_to_file($csr_file, $output_file);
89-
expect_openssl_errors('openssl_pkey_export_to_file pem', ['0906D06C']);
92+
expect_openssl_errors('openssl_pkey_export_to_file pem', [$err_pem_no_start_line]);
9093
// file to export cannot be written
9194
@openssl_pkey_export_to_file($private_key_file, $invalid_file_for_write);
9295
expect_openssl_errors('openssl_pkey_export_to_file write', ['2006D002']);
@@ -95,7 +98,7 @@ expect_openssl_errors('openssl_pkey_export_to_file write', ['2006D002']);
9598
expect_openssl_errors('openssl_pkey_export', ['06065064', '0906A065']);
9699
// invalid x509 for getting public key
97100
@openssl_pkey_get_public($private_key_file);
98-
expect_openssl_errors('openssl_pkey_get_public', ['0906D06C']);
101+
expect_openssl_errors('openssl_pkey_get_public', [$err_pem_no_start_line]);
99102
// private encrypt with unknown padding
100103
@openssl_private_encrypt("data", $crypted, $private_key_file, 1000);
101104
expect_openssl_errors('openssl_private_encrypt', ['04066076']);
@@ -105,7 +108,7 @@ expect_openssl_errors('openssl_private_decrypt', ['04065072']);
105108
// public encrypt and decrypt with failed padding check and padding
106109
@openssl_public_encrypt("data", $crypted, $public_key_file, 1000);
107110
@openssl_public_decrypt("data", $crypted, $public_key_file);
108-
expect_openssl_errors('openssl_private_(en|de)crypt padding', ['0906D06C', '04068076', '04067072']);
111+
expect_openssl_errors('openssl_private_(en|de)crypt padding', [$err_pem_no_start_line, '04068076', '04067072']);
109112

110113
// X509
111114
echo "X509 errors\n";
@@ -114,7 +117,7 @@ echo "X509 errors\n";
114117
expect_openssl_errors('openssl_x509_export_to_file open', ['02001002']);
115118
// file or str cert is not correct PEM - failing PEM_read_bio_X509 or PEM_ASN1_read_bio
116119
@openssl_x509_export_to_file($csr_file, $output_file);
117-
expect_openssl_errors('openssl_x509_export_to_file pem', ['0906D06C']);
120+
expect_openssl_errors('openssl_x509_export_to_file pem', [$err_pem_no_start_line]);
118121
// file to export cannot be written
119122
@openssl_x509_export_to_file($crt_file, $invalid_file_for_write);
120123
expect_openssl_errors('openssl_x509_export_to_file write', ['2006D002']);
@@ -129,7 +132,7 @@ echo "CSR errors\n";
129132
expect_openssl_errors('openssl_csr_get_subject open', ['02001002', '2006D080']);
130133
// file or str csr is not correct PEM - failing PEM_read_bio_X509_REQ
131134
@openssl_csr_get_subject($crt_file);
132-
expect_openssl_errors('openssl_csr_get_subjec pem', ['0906D06C']);
135+
expect_openssl_errors('openssl_csr_get_subjec pem', [$err_pem_no_start_line]);
133136

134137
// other possible cuases that are difficult to catch:
135138
// - ASN1_STRING_to_UTF8 fails in add_assoc_name_entry

0 commit comments

Comments
 (0)