@@ -793,14 +793,15 @@ def set_certificate(self, client_certificate):
793793 """Sets client certificate. Must be called
794794 BEFORE a network connection is established.
795795 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 .
797797 """
798798 if self ._debug :
799799 print ("** Setting client certificate" )
800800 if self .status == WL_CONNECTED :
801801 raise RuntimeError ("set_certificate must be called BEFORE a connection is established." )
802802 if isinstance (client_certificate , str ):
803803 client_certificate = bytes (client_certificate , 'utf-8' )
804+ assert len (client_certificate ) < 1300 , "X.509 certificate must be less than 1300 bytes."
804805 resp = self ._send_command_get_response (_SET_CLI_CERT , (client_certificate ,))
805806 if resp [0 ][0 ] != 1 :
806807 raise RuntimeError ("Failed to set client certificate" )
@@ -809,14 +810,15 @@ def set_certificate(self, client_certificate):
809810 def set_private_key (self , private_key ):
810811 """Sets private key. Must be called
811812 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 .
813814 """
814815 if self ._debug :
815816 print ("** Setting client's private key." )
816817 if self .status == WL_CONNECTED :
817818 raise RuntimeError ("set_private_key must be called BEFORE a connection is established." )
818819 if isinstance (private_key , str ):
819820 private_key = bytes (private_key , 'utf-8' )
821+ assert len (private_key ) < 1700 , "Private key must be less than 1700 bytes."
820822 resp = self ._send_command_get_response (_SET_PK , (private_key ,))
821823 if resp [0 ][0 ] != 1 :
822824 raise RuntimeError ("Failed to set private key." )
0 commit comments