@@ -79,14 +79,17 @@ while (($enc_error_new = openssl_error_string()) !== false) {
79
79
var_dump ($ error_queue_size );
80
80
echo "\n" ;
81
81
82
+ $ is_111 = OPENSSL_VERSION_NUMBER >= 0x10101000 ;
83
+ $ err_pem_no_start_line = $ is_111 ? '0909006C ' : '0906D06C ' ;
84
+
82
85
// PKEY
83
86
echo "PKEY errors \n" ;
84
87
// file for pkey (file:///) fails when opennig (BIO_new_file)
85
88
@openssl_pkey_export_to_file ("file:// " . $ invalid_file_for_read , $ output_file );
86
89
expect_openssl_errors ('openssl_pkey_export_to_file opening ' , ['02001002 ' , '2006D080 ' ]);
87
90
// file or private pkey is not correct PEM - failing PEM_read_bio_PrivateKey
88
91
@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 ]);
90
93
// file to export cannot be written
91
94
@openssl_pkey_export_to_file ($ private_key_file , $ invalid_file_for_write );
92
95
expect_openssl_errors ('openssl_pkey_export_to_file write ' , ['2006D002 ' ]);
@@ -95,7 +98,7 @@ expect_openssl_errors('openssl_pkey_export_to_file write', ['2006D002']);
95
98
expect_openssl_errors ('openssl_pkey_export ' , ['06065064 ' , '0906A065 ' ]);
96
99
// invalid x509 for getting public key
97
100
@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 ]);
99
102
// private encrypt with unknown padding
100
103
@openssl_private_encrypt ("data " , $ crypted , $ private_key_file , 1000 );
101
104
expect_openssl_errors ('openssl_private_encrypt ' , ['04066076 ' ]);
@@ -105,7 +108,7 @@ expect_openssl_errors('openssl_private_decrypt', ['04065072']);
105
108
// public encrypt and decrypt with failed padding check and padding
106
109
@openssl_public_encrypt ("data " , $ crypted , $ public_key_file , 1000 );
107
110
@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 ' ]);
109
112
110
113
// X509
111
114
echo "X509 errors \n" ;
@@ -114,7 +117,7 @@ echo "X509 errors\n";
114
117
expect_openssl_errors ('openssl_x509_export_to_file open ' , ['02001002 ' ]);
115
118
// file or str cert is not correct PEM - failing PEM_read_bio_X509 or PEM_ASN1_read_bio
116
119
@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 ]);
118
121
// file to export cannot be written
119
122
@openssl_x509_export_to_file ($ crt_file , $ invalid_file_for_write );
120
123
expect_openssl_errors ('openssl_x509_export_to_file write ' , ['2006D002 ' ]);
@@ -129,7 +132,7 @@ echo "CSR errors\n";
129
132
expect_openssl_errors ('openssl_csr_get_subject open ' , ['02001002 ' , '2006D080 ' ]);
130
133
// file or str csr is not correct PEM - failing PEM_read_bio_X509_REQ
131
134
@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 ]);
133
136
134
137
// other possible cuases that are difficult to catch:
135
138
// - ASN1_STRING_to_UTF8 fails in add_assoc_name_entry
0 commit comments