@@ -793,14 +793,15 @@ def set_certificate(self, client_certificate):
793
793
"""Sets client certificate. Must be called
794
794
BEFORE a network connection is established.
795
795
Begins with -----BEGIN CERTIFICATE-----.
796
- :param str client_certificate: User-provided client certificate.
796
+ :param str client_certificate: User-provided X.509 certificate up to 1300 bytes .
797
797
"""
798
798
if self ._debug :
799
799
print ("** Setting client certificate" )
800
800
if self .status == WL_CONNECTED :
801
801
raise RuntimeError ("set_certificate must be called BEFORE a connection is established." )
802
802
if isinstance (client_certificate , str ):
803
803
client_certificate = bytes (client_certificate , 'utf-8' )
804
+ assert len (client_certificate ) < 1300 , "X.509 certificate must be less than 1300 bytes."
804
805
resp = self ._send_command_get_response (_SET_CLI_CERT , (client_certificate ,))
805
806
if resp [0 ][0 ] != 1 :
806
807
raise RuntimeError ("Failed to set client certificate" )
@@ -809,14 +810,15 @@ def set_certificate(self, client_certificate):
809
810
def set_private_key (self , private_key ):
810
811
"""Sets private key. Must be called
811
812
BEFORE a network connection is established.
812
- :param str private_key: User-provided private key.
813
+ :param str private_key: User-provided private key up to 1700 bytes .
813
814
"""
814
815
if self ._debug :
815
816
print ("** Setting client's private key." )
816
817
if self .status == WL_CONNECTED :
817
818
raise RuntimeError ("set_private_key must be called BEFORE a connection is established." )
818
819
if isinstance (private_key , str ):
819
820
private_key = bytes (private_key , 'utf-8' )
821
+ assert len (private_key ) < 1700 , "Private key must be less than 1700 bytes."
820
822
resp = self ._send_command_get_response (_SET_PK , (private_key ,))
821
823
if resp [0 ][0 ] != 1 :
822
824
raise RuntimeError ("Failed to set private key." )
0 commit comments