Skip to content

Commit ad0aef6

Browse files
committed
Fix sm2 compatibility bugs
1 parent 5257075 commit ad0aef6

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

ext/openssl/openssl.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4950,7 +4950,21 @@ PHP_FUNCTION(openssl_pkey_get_details)
49504950
*/
49514951
#if PHP_OPENSSL_API_VERSION >= 0x30000
49524952
zval ary;
4953-
switch (EVP_PKEY_base_id(pkey)) {
4953+
int base_id = 0;
4954+
4955+
if (EVP_PKEY_id(pkey) != EVP_PKEY_KEYMGMT) {
4956+
base_id = EVP_PKEY_base_id(pkey);
4957+
} else {
4958+
const char *type_name = EVP_PKEY_get0_type_name(pkey);
4959+
if (type_name) {
4960+
int nid = OBJ_txt2nid(type_name);
4961+
if (nid != NID_undef) {
4962+
base_id = EVP_PKEY_type(nid);
4963+
}
4964+
}
4965+
}
4966+
4967+
switch (base_id) {
49544968
case EVP_PKEY_RSA:
49554969
ktype = OPENSSL_KEYTYPE_RSA;
49564970
array_init(&ary);
@@ -5013,7 +5027,9 @@ PHP_FUNCTION(openssl_pkey_get_details)
50135027
break;
50145028
}
50155029
#endif
5016-
EMPTY_SWITCH_DEFAULT_CASE();
5030+
default:
5031+
ktype = -1;
5032+
break;
50175033
}
50185034
#else
50195035
switch (EVP_PKEY_base_id(pkey)) {

0 commit comments

Comments
 (0)