<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Cannot read full CA certificate</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/67412/cannot-read-full-ca-certificate</link><description>Hello, 
 I want to read the CA certificate stored inside the modem, unfortunately the modem_key_mgmt_read function cannot read a certificate bigger than 2kb even if CONFIG_AT_CMD_RESPONSE_MAX_LEN is set to 4kb(way more than needed). It does not return</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 20 Oct 2020 15:12:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/67412/cannot-read-full-ca-certificate" /><item><title>RE: Cannot read full CA certificate</title><link>https://devzone.nordicsemi.com/thread/275994?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 15:12:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5820674-45bf-40cc-906e-4b42012ffcbc</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Yes, that certainly sounds plausible. I&amp;#39;ll inform our developers about your findings.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot read full CA certificate</title><link>https://devzone.nordicsemi.com/thread/275968?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 14:06:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:894f7b96-cadb-4061-b526-39f19c4711e9</guid><dc:creator>Vlad T</dc:creator><description>&lt;p&gt;Hi Didrik,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for your help.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s a self signed certificate generated by openssl. It&amp;#39;s just a regular x509 certificate, nothing fancy about it.&lt;/p&gt;
&lt;p&gt;I took a deeper look at at_cmd file and it seems that the parser confuses the certificate string with the AT &amp;quot;OK&amp;quot; string. The certificate stops right before the &amp;quot;OK&amp;quot; characters. What happens is as follows:&lt;/p&gt;
&lt;p&gt;- The modem returns the full certificate (at_cmd.c line 146)&lt;/p&gt;
&lt;p&gt;- at_cmd calculates the payload_len with get_return_code (at_cmd.c 177)&lt;/p&gt;
&lt;p&gt;- get_return_code calculates the length based on the position of the &amp;quot;OK&amp;quot; or &amp;quot;ERROR&amp;quot; response&lt;/p&gt;
&lt;p&gt;- get_return_code miscalculates the length of the response because strstr finds the wrongs &amp;quot;OK&amp;quot; (at_cmd.c 73)&lt;/p&gt;
&lt;p&gt;get_return_code should try to find the last &amp;quot;OK&amp;quot; or &amp;quot;ERROR&amp;quot; not the first.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vlad&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot read full CA certificate</title><link>https://devzone.nordicsemi.com/thread/275956?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 13:37:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f8550f6-f815-41bb-86bb-85893c80081c</guid><dc:creator>Didrik Rokhaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Where does the certificate come from?&lt;/p&gt;
&lt;p&gt;I have seen a similar case before, and then the issue was with the certificate itself.&lt;/p&gt;
&lt;p&gt;I also see the same behavior, but when I enable more logging, particularly in the at_cmd library, I see that the full certificate is read out of the modem:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:07:01.415,954] [1B][0m&amp;lt;dbg&amp;gt; at_cmd.at_write: Sending command 
at%cmng=2,0,0[1B][0m
[00:07:01.431,762] [1B][0m&amp;lt;dbg&amp;gt; at_cmd.at_write: Awaiting response for 
at%cmng=2,0,0[1B][0m
[00:07:01.439,605] [1B][0m&amp;lt;dbg&amp;gt; at_cmd.socket_thread_fn: at_cmd_rx 2242 bytes, %CMNG: 0,0,&amp;quot;0000000000000000000000000000000000000000000000000000000000000000&amp;quot;,&amp;quot;-----BEGIN CERTIFICATE-----
MIIGCzCCA/OgAwIBAgIUU72NL4Kzf1mkLA4CItvWJhRVA8UwDQYJKoZIhvcNAQEL
BQAwgZQxCzAJBgNVBAYTAlJPMRwwGgYDVQQKDBNSYXB0b3IgVGVjaG5vbG9naWVz
MT4wPAYDVQQLDDVSYXB0b3IgVGVjaG5vbG9naWVzIFNlbGYgU2lnbmVkIENlcnRp
ZmljYXRlIEF1dGhvcml0eTEnMCUGA1UEAwwed2lyZXBhcy5yYXB0b3ItdGVjaG5v
bG9naWVzLnJvMB4XDTIwMTAyMDA3MTQ0MVoXDTIxMTAyMDA3MTQ0MVowgZQxCzAJ
BgNVBAYTAlJPMRwwGgYDVQQKDBNSYXB0b3IgVGVjaG5vbG9naWVzMT4wPAYDVQQL
DDVSYXB0b3IgVGVjaG5vbG9naWVzIFNlbGYgU2lnbmVkIENlcnRpZmljYXRlIEF1
dGhvcml0eTEnMCUGA1UEAwwed2lyZXBhcy5yYXB0b3ItdGVjaG5vbG9naWVzLnJv
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA5okWs/YG5k63dukkeJdS
NnO9hIgKFg+5CrU2bl0guIsPBHJDp2+2EwSt0vxtoHg4TW/UiZWNE1DpUCu9sGHq
MxCK8SNdU0egEPBZXEQzycNBZlRCi97Sj0ka4hNxoV77sH9bwb52xatq9rLQ5hIW
TU4pmBcgzhpJ2htrjLVCmiuv+y3DHRxd8yqrEaRdRzKj058aumJAUDOX0+TaQe1A
v2cbu5gcg4Hqe8tbflC5jaDhgze3NTuB7O75e6nBjQkc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1FBblJcrnzVa/9EpekX9Xb1Suekm/fDACmSd0cn3I3hOKgtjIVRtqOx5s
yWVhJ5UALBvmvg1LgKgU1KH71sOqQAWuRokHUI2p7f8DHyNXUoNcDUY8Nj+JbX4H
BpxnMBPeBxzaBqxUE1Ol2pwyS9ZyZf6SZD0jxl3FJg3SDI86Z2Rh6EzJ1sQN0B6J
T9dqRC46h+0ShzkwxGIP
-----END CERTIFICATE-----
&amp;quot;
OK
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But, for some reason, the full certificate is not forwarded to the modem_key_mgmt library. The same behavior is also seen in the AT host library.&lt;/p&gt;
&lt;p&gt;I will continue to investigate why the full certificate is not forwarded to the modem_key_mgmt library.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Didrik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>