@@ -477,6 +477,7 @@ void SecureContext::Initialize(Environment* env, Local<Object> target) {
477
477
env->SetProtoMethod (t, " addRootCerts" , AddRootCerts);
478
478
env->SetProtoMethod (t, " setCipherSuites" , SetCipherSuites);
479
479
env->SetProtoMethod (t, " setCiphers" , SetCiphers);
480
+ env->SetProtoMethod (t, " setSigalgs" , SetSigalgs);
480
481
env->SetProtoMethod (t, " setECDHCurve" , SetECDHCurve);
481
482
env->SetProtoMethod (t, " setDHParam" , SetDHParam);
482
483
env->SetProtoMethod (t, " setMaxProto" , SetMaxProto);
@@ -745,6 +746,23 @@ void SecureContext::SetKey(const FunctionCallbackInfo<Value>& args) {
745
746
}
746
747
}
747
748
749
+ void SecureContext::SetSigalgs (const FunctionCallbackInfo<Value>& args) {
750
+ SecureContext* sc;
751
+ ASSIGN_OR_RETURN_UNWRAP (&sc, args.Holder ());
752
+ Environment* env = sc->env ();
753
+ ClearErrorOnReturn clear_error_on_return;
754
+
755
+ CHECK_EQ (args.Length (), 1 );
756
+ CHECK (args[0 ]->IsString ());
757
+
758
+ const node::Utf8Value sigalgs (env->isolate (), args[0 ]);
759
+
760
+ int rv = SSL_CTX_set1_sigalgs_list (sc->ctx_ .get (), *sigalgs);
761
+
762
+ if (rv == 0 ) {
763
+ return ThrowCryptoError (env, ERR_get_error ());
764
+ }
765
+ }
748
766
749
767
int SSL_CTX_get_issuer (SSL_CTX* ctx, X509* cert, X509** issuer) {
750
768
X509_STORE* store = SSL_CTX_get_cert_store (ctx);
@@ -1690,6 +1708,7 @@ void SSLWrap<Base>::AddMethods(Environment* env, Local<FunctionTemplate> t) {
1690
1708
env->SetProtoMethodNoSideEffect (t, " isSessionReused" , IsSessionReused);
1691
1709
env->SetProtoMethodNoSideEffect (t, " verifyError" , VerifyError);
1692
1710
env->SetProtoMethodNoSideEffect (t, " getCipher" , GetCipher);
1711
+ env->SetProtoMethodNoSideEffect (t, " getSharedSigalgs" , GetSharedSigalgs);
1693
1712
env->SetProtoMethod (t, " endParser" , EndParser);
1694
1713
env->SetProtoMethod (t, " certCbDone" , CertCbDone);
1695
1714
env->SetProtoMethod (t, " renegotiate" , Renegotiate);
@@ -2623,6 +2642,88 @@ void SSLWrap<Base>::GetCipher(const FunctionCallbackInfo<Value>& args) {
2623
2642
}
2624
2643
2625
2644
2645
+ template <class Base >
2646
+ void SSLWrap<Base>::GetSharedSigalgs(const FunctionCallbackInfo<Value>& args) {
2647
+ Base* w;
2648
+ ASSIGN_OR_RETURN_UNWRAP (&w, args.Holder ());
2649
+ Environment* env = w->ssl_env ();
2650
+ std::vector<Local<Value>> ret_arr;
2651
+
2652
+ SSL* ssl = w->ssl_ .get ();
2653
+ int nsig = SSL_get_shared_sigalgs (ssl, 0 , nullptr , nullptr , nullptr , nullptr ,
2654
+ nullptr );
2655
+
2656
+ for (int i = 0 ; i < nsig; i++) {
2657
+ int hash_nid;
2658
+ int sign_nid;
2659
+ std::string sig_with_md;
2660
+
2661
+ SSL_get_shared_sigalgs (ssl, i, &sign_nid, &hash_nid, nullptr , nullptr ,
2662
+ nullptr );
2663
+
2664
+ switch (sign_nid) {
2665
+ case EVP_PKEY_RSA:
2666
+ sig_with_md = " RSA+" ;
2667
+ break ;
2668
+
2669
+ case EVP_PKEY_RSA_PSS:
2670
+ sig_with_md = " RSA-PSS+" ;
2671
+ break ;
2672
+
2673
+ case EVP_PKEY_DSA:
2674
+ sig_with_md = " DSA+" ;
2675
+ break ;
2676
+
2677
+ case EVP_PKEY_EC:
2678
+ sig_with_md = " ECDSA+" ;
2679
+ break ;
2680
+
2681
+ case NID_ED25519:
2682
+ sig_with_md = " Ed25519+" ;
2683
+ break ;
2684
+
2685
+ case NID_ED448:
2686
+ sig_with_md = " Ed448+" ;
2687
+ break ;
2688
+
2689
+ case NID_id_GostR3410_2001:
2690
+ sig_with_md = " gost2001+" ;
2691
+ break ;
2692
+
2693
+ case NID_id_GostR3410_2012_256:
2694
+ sig_with_md = " gost2012_256+" ;
2695
+ break ;
2696
+
2697
+ case NID_id_GostR3410_2012_512:
2698
+ sig_with_md = " gost2012_512+" ;
2699
+ break ;
2700
+
2701
+ default :
2702
+ const char * sn = OBJ_nid2sn (sign_nid);
2703
+
2704
+ if (sn != nullptr ) {
2705
+ sig_with_md = std::string (sn) + " +" ;
2706
+ } else {
2707
+ sig_with_md = " UNDEF+" ;
2708
+ }
2709
+ break ;
2710
+ }
2711
+
2712
+ const char * sn_hash = OBJ_nid2sn (hash_nid);
2713
+ if (sn_hash != nullptr ) {
2714
+ sig_with_md += std::string (sn_hash);
2715
+ } else {
2716
+ sig_with_md += " UNDEF" ;
2717
+ }
2718
+
2719
+ ret_arr.push_back (OneByteString (env->isolate (), sig_with_md.c_str ()));
2720
+ }
2721
+
2722
+ args.GetReturnValue ().Set (
2723
+ Array::New (env->isolate (), ret_arr.data (), ret_arr.size ()));
2724
+ }
2725
+
2726
+
2626
2727
template <class Base >
2627
2728
void SSLWrap<Base>::GetProtocol(const FunctionCallbackInfo<Value>& args) {
2628
2729
Base* w;
0 commit comments