File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
src/native/libs/System.Security.Cryptography.Native Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 3131#include <openssl/sha.h>
3232#include <openssl/ssl.h>
3333#include <openssl/tls1.h>
34+ #include <openssl/ui.h>
3435#include <openssl/x509.h>
3536#include <openssl/x509v3.h>
3637
@@ -690,6 +691,8 @@ extern bool g_libSslUses32BitTime;
690691 LIGHTUP_FUNCTION(SSL_verify_client_post_handshake) \
691692 LIGHTUP_FUNCTION(SSL_set_post_handshake_auth) \
692693 REQUIRED_FUNCTION(SSL_version) \
694+ REQUIRED_FUNCTION(UI_create_method) \
695+ REQUIRED_FUNCTION(UI_destroy_method) \
693696 FALLBACK_FUNCTION(X509_check_host) \
694697 REQUIRED_FUNCTION(X509_check_purpose) \
695698 REQUIRED_FUNCTION(X509_cmp_time) \
@@ -1246,6 +1249,8 @@ extern TYPEOF(OPENSSL_gmtime)* OPENSSL_gmtime_ptr;
12461249#define SSL_set_post_handshake_auth SSL_set_post_handshake_auth_ptr
12471250#define SSL_version SSL_version_ptr
12481251#define TLS_method TLS_method_ptr
1252+ #define UI_create_method UI_create_method_ptr
1253+ #define UI_destroy_method UI_destroy_method_ptr
12491254#define X509_check_host X509_check_host_ptr
12501255#define X509_check_purpose X509_check_purpose_ptr
12511256#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(
556556 * haveEngine = 1 ;
557557 EVP_PKEY * ret = NULL ;
558558 ENGINE * engine = NULL ;
559+ UI_METHOD * ui = NULL ;
559560
560561 // Per https://github.com/openssl/openssl/discussions/21427
561562 // using EVP_PKEY after freeing ENGINE is correct.
@@ -567,12 +568,30 @@ static EVP_PKEY* LoadKeyFromEngine(
567568 {
568569 ret = load_func (engine , keyName , NULL , NULL );
569570
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+
570584 ENGINE_finish (engine );
571585 }
572586
573587 ENGINE_free (engine );
574588 }
575589
590+ if (ui )
591+ {
592+ UI_destroy_method (ui );
593+ }
594+
576595 return ret ;
577596 }
578597
You can’t perform that action at this time.
0 commit comments