<?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>Cloud TLS Certificates Deleted Themselves</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/85695/cloud-tls-certificates-deleted-themselves</link><description>Hello, 
 I have a custom board using an nRF9160 chip. It connects to the Nordic Cloud. Modem firmware 1.3.1. SDK 1.6.1. 
 
 I have seen an issue 3 times now over ~6 months of development. My device will automatically delete the SSL/TLS certificates used</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 14 Mar 2022 18:17:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/85695/cloud-tls-certificates-deleted-themselves" /><item><title>RE: Cloud TLS Certificates Deleted Themselves</title><link>https://devzone.nordicsemi.com/thread/358064?ContentTypeID=1</link><pubDate>Mon, 14 Mar 2022 18:17:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bbebae31-354c-4152-913f-d8abe7fdc236</guid><dc:creator>jdorn</dc:creator><description>&lt;p&gt;Yea, That makes sense. I will close this ticket. If the issue happens again I will open a new one.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for&amp;nbsp; your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cloud TLS Certificates Deleted Themselves</title><link>https://devzone.nordicsemi.com/thread/357819?ContentTypeID=1</link><pubDate>Mon, 14 Mar 2022 07:56:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e44526a-abc1-4071-b582-ec3de18b5a52</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user="jdorn"]I am using modem_key_mgmt_write and&amp;nbsp;&lt;span&gt;modem_key_mgmt_delete every time I run my code.&lt;/span&gt;[/quote]
&lt;p&gt;That is most likely the reason for your issue. There is no need to do this every time you run the code, only once when the credentials need to change. Have a look at how the nRF9160: HTTPS Client handles the certification provisioning&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/* Provision certificate to modem */
int cert_provision(void)
{
	int err;
	bool exists;
	int mismatch;

	/* It may be sufficient for you application to check whether the correct
	 * certificate is provisioned with a given tag directly using modem_key_mgmt_cmp().
	 * Here, for the sake of the completeness, we check that a certificate exists
	 * before comparing it with what we expect it to be.
	 */
	err = modem_key_mgmt_exists(TLS_SEC_TAG, MODEM_KEY_MGMT_CRED_TYPE_CA_CHAIN, &amp;amp;exists);
	if (err) {
		printk(&amp;quot;Failed to check for certificates err %d\n&amp;quot;, err);
		return err;
	}

	if (exists) {
		mismatch = modem_key_mgmt_cmp(TLS_SEC_TAG,
					      MODEM_KEY_MGMT_CRED_TYPE_CA_CHAIN,
					      cert, strlen(cert));
		if (!mismatch) {
			printk(&amp;quot;Certificate match\n&amp;quot;);
			return 0;
		}

		printk(&amp;quot;Certificate mismatch\n&amp;quot;);
		err = modem_key_mgmt_delete(TLS_SEC_TAG, MODEM_KEY_MGMT_CRED_TYPE_CA_CHAIN);
		if (err) {
			printk(&amp;quot;Failed to delete existing certificate, err %d\n&amp;quot;, err);
		}
	}

	printk(&amp;quot;Provisioning certificate\n&amp;quot;);

	/*  Provision certificate to the modem */
	err = modem_key_mgmt_write(TLS_SEC_TAG,
				   MODEM_KEY_MGMT_CRED_TYPE_CA_CHAIN,
				   cert, sizeof(cert) - 1);
	if (err) {
		printk(&amp;quot;Failed to provision certificate, err %d\n&amp;quot;, err);
		return err;
	}

	return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This function checks if certificates are available in&amp;nbsp;given security tag, compares it, and deletes and write new if needed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cloud TLS Certificates Deleted Themselves</title><link>https://devzone.nordicsemi.com/thread/357709?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2022 14:36:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3dcba39a-2115-4d56-a7ad-96f9705d2452</guid><dc:creator>jdorn</dc:creator><description>&lt;p&gt;This is a custom project.&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;have not actually seen this error occur, only the results of this error. And I am not able to reproduce it. it happens randomly, months apart. It has happened on different prototypes.&lt;/p&gt;
&lt;p&gt;Is it possible that there is a limit to the number of times the certificate section can be written to before the storage location cleans itself? I am using modem_key_mgmt_write and&amp;nbsp;&lt;span&gt;modem_key_mgmt_delete every time I run my code.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;or is there potentially some kind of hardware security feature that could be triggered by ESD?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cloud TLS Certificates Deleted Themselves</title><link>https://devzone.nordicsemi.com/thread/357653?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2022 12:34:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98f4f1fa-f48a-4cb7-9228-55dcfd0eb67c</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I&amp;#39;ve never heard of an issue like your describe. Can you please provide log output when this occurs? Also, please enable debug logs to provide more information of what is going on in the background. Is this your own custom project?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;We might also need a modem trace of this issue.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;From the &lt;a href="https://infocenter.nordicsemi.com/topic/comp_matrix_nrf9160/COMP/nrf9160/nrf9160_modem_fw.html"&gt;modem firmware compatibility matrix&lt;/a&gt;, the modem fw 1.3.1 is not compatible with nRF Connect SDK v1.6.1. But I think it should either way.&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>