File tree 2 files changed +24
-0
lines changed
src/native/libs/System.Security.Cryptography.Native
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 31
31
#include <openssl/sha.h>
32
32
#include <openssl/ssl.h>
33
33
#include <openssl/tls1.h>
34
+ #include <openssl/ui.h>
34
35
#include <openssl/x509.h>
35
36
#include <openssl/x509v3.h>
36
37
@@ -690,6 +691,8 @@ extern bool g_libSslUses32BitTime;
690
691
LIGHTUP_FUNCTION(SSL_verify_client_post_handshake) \
691
692
LIGHTUP_FUNCTION(SSL_set_post_handshake_auth) \
692
693
REQUIRED_FUNCTION(SSL_version) \
694
+ REQUIRED_FUNCTION(UI_create_method) \
695
+ REQUIRED_FUNCTION(UI_destroy_method) \
693
696
FALLBACK_FUNCTION(X509_check_host) \
694
697
REQUIRED_FUNCTION(X509_check_purpose) \
695
698
REQUIRED_FUNCTION(X509_cmp_time) \
@@ -1246,6 +1249,8 @@ extern TYPEOF(OPENSSL_gmtime)* OPENSSL_gmtime_ptr;
1246
1249
#define SSL_set_post_handshake_auth SSL_set_post_handshake_auth_ptr
1247
1250
#define SSL_version SSL_version_ptr
1248
1251
#define TLS_method TLS_method_ptr
1252
+ #define UI_create_method UI_create_method_ptr
1253
+ #define UI_destroy_method UI_destroy_method_ptr
1249
1254
#define X509_check_host X509_check_host_ptr
1250
1255
#define X509_check_purpose X509_check_purpose_ptr
1251
1256
#define X509_cmp_time X509_cmp_time_ptr
Original file line number Diff line number Diff line change @@ -556,6 +556,7 @@ static EVP_PKEY* LoadKeyFromEngine(
556
556
* haveEngine = 1 ;
557
557
EVP_PKEY * ret = NULL ;
558
558
ENGINE * engine = NULL ;
559
+ UI_METHOD * ui = NULL ;
559
560
560
561
// Per https://github.com/openssl/openssl/discussions/21427
561
562
// using EVP_PKEY after freeing ENGINE is correct.
@@ -567,12 +568,30 @@ static EVP_PKEY* LoadKeyFromEngine(
567
568
{
568
569
ret = load_func (engine , keyName , NULL , NULL );
569
570
571
+ if (ret == NULL )
572
+ {
573
+ // Some engines do not tolerate having NULL passed to the ui_method parameter.
574
+ // We re-try with a non-NULL UI_METHOD.
575
+ ERR_clear_error ();
576
+ ui = UI_create_method (".NET NULL UI" );
577
+
578
+ if (ui )
579
+ {
580
+ ret = load_func (engine , keyName , ui , NULL );
581
+ }
582
+ }
583
+
570
584
ENGINE_finish (engine );
571
585
}
572
586
573
587
ENGINE_free (engine );
574
588
}
575
589
590
+ if (ui )
591
+ {
592
+ UI_destroy_method (ui );
593
+ }
594
+
576
595
return ret ;
577
596
}
578
597
You can’t perform that action at this time.
0 commit comments