@@ -85,6 +85,8 @@ void WiFiClientSecure::_clearAuthenticationSettings() {
85
85
86
86
87
87
WiFiClientSecure::WiFiClientSecure () : WiFiClient() {
88
+ _cipher_list = NULL ;
89
+ _cipher_cnt = 0 ;
88
90
_clear ();
89
91
_clearAuthenticationSettings ();
90
92
_certStore = nullptr ; // Don't want to remove cert store on a clear, should be long lived
@@ -685,6 +687,13 @@ extern "C" {
685
687
BR_TLS_RSA_WITH_3DES_EDE_CBC_SHA
686
688
};
687
689
690
+ // For apps which want to use less secure but faster axTLS ciphers, only
691
+ static const uint16_t axtls_suites_P[] PROGMEM = {
692
+ BR_TLS_RSA_WITH_AES_256_CBC_SHA256,
693
+ BR_TLS_RSA_WITH_AES_128_CBC_SHA256,
694
+ BR_TLS_RSA_WITH_AES_256_CBC_SHA,
695
+ BR_TLS_RSA_WITH_AES_128_CBC_SHA };
696
+
688
697
// Install hashes into the SSL engine
689
698
static void br_ssl_client_install_hashes (br_ssl_engine_context *eng) {
690
699
br_ssl_engine_set_hash (eng, br_md5_ID, &br_md5_vtable);
@@ -705,9 +714,9 @@ extern "C" {
705
714
}
706
715
707
716
// Default initializion for our SSL clients
708
- static void br_ssl_client_base_init (br_ssl_client_context *cc) {
709
- uint16_t suites[sizeof (suites_P) / sizeof ( uint16_t ) ];
710
- memcpy_P (suites, suites_P, sizeof (suites_P ));
717
+ static void br_ssl_client_base_init (br_ssl_client_context *cc, const uint16_t *cipher_list, int cipher_cnt ) {
718
+ uint16_t suites[cipher_cnt ];
719
+ memcpy_P (suites, cipher_list, cipher_cnt * sizeof (cipher_list[ 0 ] ));
711
720
br_ssl_client_zero (cc);
712
721
br_ssl_engine_set_versions (&cc->eng , BR_TLS10, BR_TLS12);
713
722
br_ssl_engine_set_suites (&cc->eng , suites, (sizeof suites) / (sizeof suites[0 ]));
@@ -726,6 +735,12 @@ extern "C" {
726
735
727
736
}
728
737
738
+ // Set the AXTLS ciphers as the only ones allowed
739
+ void WiFiClientSecure::setAxTLSCiphers ()
740
+ {
741
+ setCiphers (axtls_suites_P, sizeof (axtls_suites_P)/sizeof (axtls_suites_P[0 ]));
742
+ }
743
+
729
744
// Installs the appropriate X509 cert validation method for a client connection
730
745
bool WiFiClientSecure::_installClientX509Validator () {
731
746
if (_use_insecure || _use_fingerprint || _use_self_signed) {
@@ -787,7 +802,11 @@ bool WiFiClientSecure::_connectSSL(const char* hostName) {
787
802
return false ;
788
803
}
789
804
790
- br_ssl_client_base_init (_sc.get ());
805
+ // If no cipher list yet set, use defaults
806
+ if (_cipher_list == NULL ) {
807
+ setCiphers (suites_P, sizeof (suites_P) / sizeof (uint16_t ));
808
+ }
809
+ br_ssl_client_base_init (_sc.get (), _cipher_list, _cipher_cnt);
791
810
// Only failure possible in the installation is OOM
792
811
if (!_installClientX509Validator ()) {
793
812
_freeSSL ();
0 commit comments