@@ -58,7 +58,7 @@ def list(self, tag = None, type: CredType = CredType.ANY) -> List[Credential]:
5858 cmd = f'{ cmd } ,{ CredType (type ).value } '
5959
6060 self .command_interface .at_command (cmd , wait_for_result = False )
61- result , response = self .command_interface .comms .expect_response ("OK" , "ERROR" , "%CMNG" )
61+ result , response = self .command_interface .comms .expect_response ("OK" , "ERROR" , "%CMNG: " )
6262 if not result :
6363 raise RuntimeError ("Failed to list credentials" )
6464 response_lines = response .splitlines ()
@@ -101,12 +101,14 @@ def keygen(self, tag: int, file: io.BufferedIOBase, attributes: str = ''):
101101 cmd = f'{ cmd } ,"{ attributes } "'
102102
103103 self .command_interface .at_command (cmd , wait_for_result = False )
104- result , response = self .command_interface .comms .expect_response ("OK" , "ERROR" , "%KEYGEN" )
104+ result , response = self .command_interface .comms .expect_response ("OK" , "ERROR" , "%KEYGEN: " )
105105
106- if result :
107- keygen_output = response .replace ('%KEYGEN: "' , '' )
108- csr_der_b64 = keygen_output .split ('.' )[0 ]
109- csr_der_bytes = base64 .urlsafe_b64decode (csr_der_b64 + '===' )
110- file .write (csr_der_bytes )
106+ if not result :
107+ raise RuntimeError ("Failed to generate key" )
108+
109+ keygen_output = response .replace ('%KEYGEN: "' , '' )
110+ csr_der_b64 = keygen_output .split ('.' )[0 ]
111+ csr_der_bytes = base64 .urlsafe_b64decode (csr_der_b64 + '===' )
112+ file .write (csr_der_bytes )
111113
112114 file .close ()
0 commit comments