@@ -393,6 +393,26 @@ static int int_load(dynamic_data_ctx *ctx)
393
393
return 0 ;
394
394
}
395
395
396
+ /*
397
+ * Unfortunately the version checker does not distinguish between
398
+ * engines built for openssl 1.1.x and openssl 3.x, but loading
399
+ * an engine that is built for openssl 3.x will cause a fatal
400
+ * error. Detect such engines, since EVP_PKEY_get_base_id is exported
401
+ * as a function in openssl 3.x, while it is named EVP_PKEY_base_id
402
+ * in openssl 1.1.x. Therefore we take the presence of that symbol
403
+ * as an indication that the engine will be incompatible.
404
+ */
405
+ static int using_libcrypto_3 (dynamic_data_ctx * ctx )
406
+ {
407
+ int ret ;
408
+
409
+ ERR_set_mark ();
410
+ ret = DSO_bind_func (ctx -> dynamic_dso , "EVP_PKEY_get_base_id" ) != NULL ;
411
+ ERR_pop_to_mark ();
412
+
413
+ return ret ;
414
+ }
415
+
396
416
static int dynamic_load (ENGINE * e , dynamic_data_ctx * ctx )
397
417
{
398
418
ENGINE cpy ;
@@ -442,18 +462,9 @@ static int dynamic_load(ENGINE *e, dynamic_data_ctx *ctx)
442
462
/*
443
463
* We fail if the version checker veto'd the load *or* if it is
444
464
* deferring to us (by returning its version) and we think it is too
445
- * old.
446
- * Unfortunately the version checker does not distinguish between
447
- * engines built for openssl 1.1.x and openssl 3.x, but loading
448
- * an engine that is built for openssl 3.x will cause a fatal
449
- * error. Detect such engines, since EVP_PKEY_get_base_id is exported
450
- * as a function in openssl 3.x, while it is named EVP_PKEY_base_id
451
- * in openssl 1.1.x. Therefore we take the presence of that symbol
452
- * as an indication that the engine will be incompatible.
465
+ * old. Also fail if this is engine for openssl 3.x.
453
466
*/
454
- if (vcheck_res < OSSL_DYNAMIC_OLDEST
455
- || DSO_bind_func (ctx -> dynamic_dso ,
456
- "EVP_PKEY_get_base_id" ) != NULL ) {
467
+ if (vcheck_res < OSSL_DYNAMIC_OLDEST || using_libcrypto_3 (ctx )) {
457
468
/* Fail */
458
469
ctx -> bind_engine = NULL ;
459
470
ctx -> v_check = NULL ;
0 commit comments