<?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>Problem Parsing pem certificate</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/115186/problem-parsing-pem-certificate</link><description>I am using mbedtls to parse a certificate. The code is as follows: 
 It builds successfully but when I flash I get the following error: 
 Failed to parse certificate: -9774 i.e -0x262E in hex which does not correspond to an enumerator 
 Requesting he</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 11 Oct 2024 12:48:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/115186/problem-parsing-pem-certificate" /><item><title>RE: Problem Parsing pem certificate</title><link>https://devzone.nordicsemi.com/thread/505888?ContentTypeID=1</link><pubDate>Fri, 11 Oct 2024 12:48:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65612fb6-6638-45d1-951e-40bddb9bcc15</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The sample that I used is with the _ns board prefix:&lt;/p&gt;
[quote user="hkn"]I added your code to https_client sample and ran it for the nrf7002dk_nrf5340_cpuapp_ns target:[/quote]
&lt;p&gt;Could you try this and share your results? And if you get the expected result from this sample, please check your configuration compared to the default configuration that I posted here:&lt;/p&gt;
[quote user="hkn"]With the default configuration here:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v2.6.1/samples/net/https_client/boards/nrf7002dk_nrf5340_cpuapp_ns.conf#L0-L1"&gt;https://github.com/nrfconnect/sdk-nrf/blob/v2.6.1/samples/net/https_client/boards/nrf7002dk_nrf5340_cpuapp_ns.conf#L0-L1&lt;/a&gt;[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem Parsing pem certificate</title><link>https://devzone.nordicsemi.com/thread/505849?ContentTypeID=1</link><pubDate>Fri, 11 Oct 2024 09:14:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb2b08a5-50af-48db-a092-9aa3b44f16ae</guid><dc:creator>Utkarsh</dc:creator><description>&lt;p&gt;I have tried various configs but the code could not build fro nrf5340dk_cpuapp&lt;/p&gt;
&lt;p&gt;Requesting help regarding this&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem Parsing pem certificate</title><link>https://devzone.nordicsemi.com/thread/504940?ContentTypeID=1</link><pubDate>Fri, 04 Oct 2024 07:55:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eeb29de9-5105-4fdd-946b-c8944c8626cd</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I added your code to https_client sample and ran it for the nrf7002dk_nrf5340_cpuapp_ns target:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting nRF Connect SDK v3.5.99-ncs1-1 ***
HTTPS client sample started
Dev certificate parsing successful
CA certificate parsing successful
Verfication successful
EC Public Key
RSA Public Key
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Added your code that you posted in the thread yesterday:&lt;/p&gt;
[quote user="Utkarsh-"]There is now a problem with verifying my certificate with the ca, my code is as follows[/quote]
&lt;p&gt;+ these header includes:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;quot;mbedtls/net_sockets.h&amp;quot;
#include &amp;quot;mbedtls/debug.h&amp;quot;
#include &amp;quot;mbedtls/ssl.h&amp;quot;
#include &amp;quot;mbedtls/entropy.h&amp;quot;
#include &amp;quot;mbedtls/ctr_drbg.h&amp;quot;
#include &amp;quot;mbedtls/error.h&amp;quot;
#include &amp;quot;mbedtls/timing.h&amp;quot;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;With the default configuration here:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v2.6.1/samples/net/https_client/boards/nrf7002dk_nrf5340_cpuapp_ns.conf#L0-L1"&gt;https://github.com/nrfconnect/sdk-nrf/blob/v2.6.1/samples/net/https_client/boards/nrf7002dk_nrf5340_cpuapp_ns.conf#L0-L1&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem Parsing pem certificate</title><link>https://devzone.nordicsemi.com/thread/504914?ContentTypeID=1</link><pubDate>Fri, 04 Oct 2024 03:42:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b98edca3-7b8e-4cbf-a2df-8b635d0f4511</guid><dc:creator>Utkarsh</dc:creator><description>&lt;p&gt;I have created my own root CA Certificate by generating a self signed certificate and I have used it to sign the device certificate.&lt;br /&gt;These are the steps I followed on openssl:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Generate Root CA RSA Key&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;openssl genrsa -out rootCA.key 2048&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;To pass data to be incorporated into the root certificate&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Display root certificate&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;openssl x509 -in rootCA.pem -text -noout&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Convert csr into signed certificate&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&amp;nbsp;openssl x509 -req -in CSR/newcert.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 365 -sha256&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Verify created certificate&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;openssl verify -CAfile rootCA.pem device.crt&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Display generated certificate&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;openssl x509 -in device.pem -text&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem Parsing pem certificate</title><link>https://devzone.nordicsemi.com/thread/504808?ContentTypeID=1</link><pubDate>Thu, 03 Oct 2024 10:34:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:efcad571-fcc9-4d92-bd5d-9f0ea9a1b9ab</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Which root CA are you using?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem Parsing pem certificate</title><link>https://devzone.nordicsemi.com/thread/504807?ContentTypeID=1</link><pubDate>Thu, 03 Oct 2024 10:25:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:228f283d-ecc2-4bc0-9497-d9d9afc9d658</guid><dc:creator>Utkarsh</dc:creator><description>&lt;p&gt;Yes I am getting ok as output there.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem Parsing pem certificate</title><link>https://devzone.nordicsemi.com/thread/504805?ContentTypeID=1</link><pubDate>Thu, 03 Oct 2024 10:21:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5938091c-dbde-4a0d-a46e-482ca460d7c3</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Have you tried the same exercise with openssl?&lt;/p&gt;
&lt;p&gt;Which root CA are you using?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem Parsing pem certificate</title><link>https://devzone.nordicsemi.com/thread/504802?ContentTypeID=1</link><pubDate>Thu, 03 Oct 2024 09:54:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95c4cd7e-a4bc-4f1f-b201-222547c5a972</guid><dc:creator>Utkarsh</dc:creator><description>&lt;p&gt;Actually, I have uploaded the rot CA certificate and am validating a certificate generated by the CA.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem Parsing pem certificate</title><link>https://devzone.nordicsemi.com/thread/504790?ContentTypeID=1</link><pubDate>Thu, 03 Oct 2024 08:15:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8944d3c5-3f69-4743-894d-b8608bc12920</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;You will need to add the root CA to be able to validate a intermediate CA or similar. I would recommend that you do this first with openssl, and get that working, and then add your corresponding CA chain to mbedtls for verification.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;H&amp;aring;kon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem Parsing pem certificate</title><link>https://devzone.nordicsemi.com/thread/504780?ContentTypeID=1</link><pubDate>Thu, 03 Oct 2024 06:46:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f6c3841-73e1-4b8b-a7b6-7ca9fa12593e</guid><dc:creator>Utkarsh</dc:creator><description>&lt;p&gt;There is now a problem with verifying my certificate with the ca, my code is as follows&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int certificate_parsing(void){
	psa_crypto_init();
    
    const char *cert_pem = &amp;quot;-----BEGIN CERTIFICATE-----\n&amp;quot;
&amp;quot;MIIC4zCCAcsCFG9Cigrq0kDK6cSGFwDtcCgCnrZeMA0GCSqGSIb3DQEBCwUAMIGh\n&amp;quot;
&amp;quot;MQswCQYDVQQGEwJJTjEUMBIGA1UECAwLTWFoYXJhc2h0cmExDzANBgNVBAcMBk11\n&amp;quot;
&amp;quot;bWJhaTEnMCUGA1UECgweVElIIEZvdW5kYXRpb24gZm9yIElvVCBhbmQgSW9FMRMw\n&amp;quot;
&amp;quot;EQYDVQQLDApOZXR3b3JraW5nMQswCQYDVQQDDAJVRzEgMB4GCSqGSIb3DQEJARYR\n&amp;quot;
&amp;quot;YWRtaW5AdGloaWl0Yi5vcmcwHhcNMjQwOTMwMDM1NTUwWhcNMjUwOTMwMDM1NTUw\n&amp;quot;
&amp;quot;WjCBhDELMAkGA1UEBhMCSU4xJzAlBgNVBAoMHlRJSCBGb3VuZGF0aW9uIGZvciBJ\n&amp;quot;
&amp;quot;b1QgYW5kIElvRTEWMBQGA1UEAwwNRGV2aWNlIFVVSUQgOjEUMBIGA1UECAwLTWFo\n&amp;quot;
&amp;quot;YXJhc2h0cmExDzANBgNVBAcMBk11bWJhaTENMAsGA1UECwwEdGVzdDBZMBMGByqG\n&amp;quot;
&amp;quot;SM49AgEGCCqGSM49AwEHA0IABB8v+LW2DEgP4DZHWURAk6OZ2NuOyyk+r+nAeRZ4\n&amp;quot;
&amp;quot;Bu4q+Vu/sr4OF0vHSSNZTuQ/aXKtHxiLm7A1btg9Obf9PbswDQYJKoZIhvcNAQEL\n&amp;quot;
&amp;quot;BQADggEBACMkpyX9CZJASR0W0/9+G2pgpbkj/klqXcYT+f3jRXDhDdvhgdVXq9sq\n&amp;quot;
&amp;quot;S9HIdz5vGclFkL3/xpJ3R8xTcZS6irLLR5vCvogw+yjsP7zEtCOi55F5EwvaJc0I\n&amp;quot;
&amp;quot;PdA3gUoVOh7zqRNIdG66/KefQgSwAWLXlXniwBJHBKKpJRqbOvcGcYcQ9tE+oKY/\n&amp;quot;
&amp;quot;nLfOaQ//lgALndmxD5bQP7aupkUR2lPqw9V9Q+7T1Cb0cdPTDOJ7hUhi00TcGx4T\n&amp;quot;
&amp;quot;Gw7IEvCHNGISBN7v/JqZrDlRKnczBJJ6tBfIkCVpXjjP1Lcxsp0gJpcwo/YMWKR/\n&amp;quot;
&amp;quot;NyEqtogVRSUDtfPyj46Sl3qoiX0pdsg=\n&amp;quot;
&amp;quot;-----END CERTIFICATE-----&amp;quot;;


	const char *ca =&amp;quot;-----BEGIN CERTIFICATE-----\n&amp;quot;
&amp;quot;MIIEJTCCAw2gAwIBAgIUT2Hn8xUWBIbjmNlIWS33Cb2WkyIwDQYJKoZIhvcNAQEL\n&amp;quot;
&amp;quot;BQAwgaExCzAJBgNVBAYTAklOMRQwEgYDVQQIDAtNYWhhcmFzaHRyYTEPMA0GA1UE\n&amp;quot;
&amp;quot;BwwGTXVtYmFpMScwJQYDVQQKDB5USUggRm91bmRhdGlvbiBmb3IgSW9UIGFuZCBJ\n&amp;quot;
&amp;quot;b0UxEzARBgNVBAsMCk5ldHdvcmtpbmcxCzAJBgNVBAMMAlVHMSAwHgYJKoZIhvcN\n&amp;quot;
&amp;quot;AQkBFhFhZG1pbkB0aWhpaXRiLm9yZzAeFw0yNDA5MzAwMzQ0MjNaFw0yNzA3MjEw\n&amp;quot;
&amp;quot;MzQ0MjNaMIGhMQswCQYDVQQGEwJJTjEUMBIGA1UECAwLTWFoYXJhc2h0cmExDzAN\n&amp;quot;
&amp;quot;BgNVBAcMBk11bWJhaTEnMCUGA1UECgweVElIIEZvdW5kYXRpb24gZm9yIElvVCBh\n&amp;quot;
&amp;quot;bmQgSW9FMRMwEQYDVQQLDApOZXR3b3JraW5nMQswCQYDVQQDDAJVRzEgMB4GCSqG\n&amp;quot;
&amp;quot;SIb3DQEJARYRYWRtaW5AdGloaWl0Yi5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IB\n&amp;quot;
&amp;quot;DwAwggEKAoIBAQCi1hDWy6W5/cO9wlwet/FXH2rrXH6naaql/9oueCQyH6J/OQzs\n&amp;quot;
&amp;quot;hq9/81CcKY7jC6cQxT+Pg4ZJIBobf0Hrle/QFxoGUEz+/7w9MvrvYcsK94qdI7Lr\n&amp;quot;
&amp;quot;VUTnlIeUDCXZwMM2Mwimz1kREAN2KJcGcVraT/mtUFHXTpBu4Sr4SxVByRe0BfV6\n&amp;quot;
&amp;quot;HSbpDej6LbCwwo2bIjyUsgoteXhzsAAOiM0NG82uonvUw2RWBJuPedbkHPAlzdOp\n&amp;quot;
&amp;quot;nfnxXLX4srp/jvYssBpCiCNSAxBvQY0kJ6fHou7QWOP4I8vbt5E2U7CYAxBTXuVq\n&amp;quot;
&amp;quot;EWUo7lF/+Wnwj+SAb7dro7DZic3YWP1QbbOnAgMBAAGjUzBRMB0GA1UdDgQWBBQv\n&amp;quot;
&amp;quot;V84c8zzmyItmRnfJh45dVAW/ITAfBgNVHSMEGDAWgBQvV84c8zzmyItmRnfJh45d\n&amp;quot;
&amp;quot;VAW/ITAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQANi/+CtqSe\n&amp;quot;
&amp;quot;rS1X/tCBowKXd6GHYs49WOHG/Dpw6JIWUqNXP+V2v10lIQVlDKtGASSeVhHngT93\n&amp;quot;
&amp;quot;PaPEZEctCLi/vd6xVSEV7x2AzVjgoZE52jiQedfU82+i7ouYueWtxKGbTMpqkFWI\n&amp;quot;
&amp;quot;V1anxR6A/4HNzOPU9Dee5bR2wbr0t/+MrCkdt7dOzj68mthLT1LgNLH4eVsSamQb\n&amp;quot;
&amp;quot;WT5s/719J1h17Dlb/RolrnefQCEwreyTap/Pjsu7sTQ+cGOZJhGQCXEwRRwwv6FN\n&amp;quot;
&amp;quot;bHDdut72BckkJt/d8fIMrfW0CPHx/UL1rfMbQgCugufPYVVH5aOq0CLUryt3sVip\n&amp;quot;
&amp;quot;YRQjRK+RwdAA\n&amp;quot;
&amp;quot;-----END CERTIFICATE-----&amp;quot;;
	int ret;
	uint32_t flags;
    mbedtls_x509_crt cert;
	mbedtls_x509_crt cacrt;
	mbedtls_x509_crl crl;
	
    mbedtls_x509_crt_init(&amp;amp;cert);
	mbedtls_x509_crt_init(&amp;amp;cacrt);
	mbedtls_x509_crl_init(&amp;amp;crl);

     ret = mbedtls_x509_crt_parse(&amp;amp;cert, (const unsigned char *)cert_pem, strlen(cert_pem) + 1);
     if (ret &amp;lt; 0) {
         printf(&amp;quot;Failed to dev certificate: %d\n&amp;quot;, ret);
     }
	 else{
		printf(&amp;quot;Dev certificate parsing successful&amp;quot;);
	 }

	 ret = mbedtls_x509_crt_parse(&amp;amp;cacrt, (const unsigned char *)ca, strlen(ca) + 1);
    if (ret &amp;lt; 0) {
        printf(&amp;quot;Failed to ca certificate: %d\n&amp;quot;, ret);
    }
	else{
		printf(&amp;quot;CA certificate parsing successful&amp;quot;);
	 }


	ret = mbedtls_x509_crt_verify(&amp;amp;cert,&amp;amp;cacrt,&amp;amp;crl,NULL,&amp;amp;flags,NULL,NULL);
	if (ret &amp;lt; 0) {
		if (ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED) {
    	printf(&amp;quot;Verification failed with flags: %u\n&amp;quot;, flags);
		}
        printf(&amp;quot;Failed to verify certificate: %d\n&amp;quot;, ret);
    }
	else{
		printf(&amp;quot;Verfication successful&amp;quot;);
	 }

	mbedtls_pk_context *cert_public_key = &amp;amp;cert.pk;

	if (mbedtls_pk_can_do(cert_public_key, MBEDTLS_PK_RSA)) {
        printf(&amp;quot;RSA Public Key\n&amp;quot;);
    } else if (mbedtls_pk_can_do(cert_public_key, MBEDTLS_PK_ECKEY)) {
        printf(&amp;quot;EC Public Key\n&amp;quot;);
    } else {
        printf(&amp;quot;Unknown Public Key Type\n&amp;quot;);
    }

	mbedtls_pk_context *ca_public_key = &amp;amp;cacrt.pk;

	if (mbedtls_pk_can_do(ca_public_key, MBEDTLS_PK_RSA)) {
        printf(&amp;quot;RSA Public Key\n&amp;quot;);
    } else if (mbedtls_pk_can_do(ca_public_key, MBEDTLS_PK_ECKEY)) {
        printf(&amp;quot;EC Public Key\n&amp;quot;);
    } else {
        printf(&amp;quot;Unknown Public Key Type\n&amp;quot;);
    }

	mbedtls_x509_crl_free(&amp;amp;crl);
    mbedtls_x509_crt_free(&amp;amp;cert);
	mbedtls_x509_crt_free(&amp;amp;cacrt);

    return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The error flag indicates&lt;/p&gt;
&lt;p&gt;&amp;quot;MBEDTLS_X509_BADCERT_NOT_TRUSTED&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem Parsing pem certificate</title><link>https://devzone.nordicsemi.com/thread/504701?ContentTypeID=1</link><pubDate>Wed, 02 Oct 2024 13:08:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87cbb367-8433-4a16-992b-512a91caec8d</guid><dc:creator>Utkarsh</dc:creator><description>&lt;p&gt;Thank you for the help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem Parsing pem certificate</title><link>https://devzone.nordicsemi.com/thread/504692?ContentTypeID=1</link><pubDate>Wed, 02 Oct 2024 12:21:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:793d25f7-cf98-4904-bf84-9dc001948766</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You changed your working certificate to a non-working format. You&amp;#39;re lacking the newlines (ie. \n) now.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem Parsing pem certificate</title><link>https://devzone.nordicsemi.com/thread/504668?ContentTypeID=1</link><pubDate>Wed, 02 Oct 2024 11:13:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cefb6432-b3e3-4c48-b37f-439bcd21a220</guid><dc:creator>Utkarsh</dc:creator><description>&lt;p&gt;I am still getting the error&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT&lt;/span&gt;&lt;span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;-&lt;/span&gt;&lt;span&gt;0x2780&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;After adding the above configs&lt;br /&gt;&lt;br /&gt;I have two certificates one with rsa keys and another with ecdsa keys&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem Parsing pem certificate</title><link>https://devzone.nordicsemi.com/thread/504663?ContentTypeID=1</link><pubDate>Wed, 02 Oct 2024 10:58:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:21f1a047-edff-46c7-983c-a52cbcedd4d9</guid><dc:creator>Utkarsh</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
# The Zephyr CMSIS emulation assumes that ticks are ms, currently
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000

CONFIG_MAIN_STACK_SIZE=8192
CONFIG_HEAP_MEM_POOL_SIZE=8192

# Enable logging
CONFIG_CONSOLE=y
CONFIG_LOG=y

# Enable nordic security backend and PSA APIs
CONFIG_NRF_SECURITY=y
CONFIG_MBEDTLS_PSA_CRYPTO_C=y

CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_HEAP_SIZE=8192

CONFIG_PSA_WANT_ALG_ECDSA=y
CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE=y
CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT=y
CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT=y
CONFIG_PSA_WANT_ECC_SECP_R1_256=y
CONFIG_PSA_WANT_ALG_SHA_256=y

# For key generation
CONFIG_PSA_WANT_GENERATE_RANDOM=y

#----------------------------- Below is what I added beyond ECDSA sample defaults

# mbed TLS and security
CONFIG_MBEDTLS_PK_C=y

CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_HEAP_SIZE=32768
CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=2304
CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=2304
CONFIG_MBEDTLS_TLS_LIBRARY=y
CONFIG_MBEDTLS_X509_LIBRARY=y
CONFIG_NRF_SECURITY_ADVANCED=y

# NB: This list of PSA dependencies may be too long
CONFIG_PSA_WANT_GENERATE_RANDOM=y
CONFIG_PSA_WANT_KEY_TYPE_AES=y
CONFIG_PSA_WANT_ALG_CCM=y
CONFIG_PSA_WANT_ALG_GCM=y
CONFIG_PSA_WANT_ALG_CHACHA20_POLY1305=y
CONFIG_PSA_WANT_ALG_CMAC=y
CONFIG_PSA_WANT_ALG_HMAC=y
CONFIG_PSA_WANT_ALG_SHA_1=y
CONFIG_PSA_WANT_ALG_SHA_224=y
CONFIG_PSA_WANT_ALG_SHA_256=y
CONFIG_PSA_WANT_ALG_SHA_384=y
CONFIG_PSA_WANT_ALG_SHA_512=y
CONFIG_PSA_WANT_ALG_ECB_NO_PADDING=y
CONFIG_PSA_WANT_ALG_CBC_NO_PADDING=y
CONFIG_PSA_WANT_ALG_CBC_PKCS7=y
CONFIG_PSA_WANT_ALG_CTR=y
CONFIG_PSA_WANT_ALG_HKDF=y
CONFIG_PSA_WANT_ALG_TLS12_PRF=y
CONFIG_PSA_WANT_ALG_ECDH=y
CONFIG_PSA_WANT_ALG_ECDSA=y
CONFIG_PSA_WANT_ALG_DETERMINISTIC_ECDSA=y
CONFIG_PSA_WANT_ECC_SECP_R1_256=y
CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT=y
CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT=y
#CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE=y
CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE=y
CONFIG_PSA_WANT_ALG_STREAM_CIPHER=y
CONFIG_PSA_WANT_KEY_TYPE_CHACHA20=y
CONFIG_PSA_WANT_ALG_TLS12_PSK_TO_MS=y

# ------------------ My custom adds
CONFIG_LOG_MODE_IMMEDIATE=y

# Enable X509 configs
CONFIG_MBEDTLS_X509_CREATE_C=y
CONFIG_MBEDTLS_X509_CSR_WRITE_C=y

# Enable JSON for output
CONFIG_JSON_LIBRARY=y

CONFIG_MBEDTLS_DEBUG_C=y
CONFIG_PSA_WANT_ECC_SECP_K1_256=y

# dependencies for CONFIG_MBEDTLS_RSA_C
CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y
CONFIG_PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY=y
CONFIG_PSA_WANT_RSA_KEY_SIZE_4096=y

CONFIG_PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY=y
CONFIG_PSA_WANT_ALG_ECDSA_ANY=y
CONFIG_PSA_WANT_ECC_SECP_R1_256=y
CONFIG_PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY=y
CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT=y
CONFIG_MBEDTLS_X509_USE_C=y
CONFIG_MBEDTLS_X509_CRT_PARSE_C=y
CONFIG_MBEDTLS_ECDSA_C=y
CONFIG_MBEDTLS_X509_CHECK_KEY_USAGE=y
CONFIG_MBEDTLS_PK_WRITE_C=y
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The certificate has ecdsa keys what should be the configs for them?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem Parsing pem certificate</title><link>https://devzone.nordicsemi.com/thread/504652?ContentTypeID=1</link><pubDate>Wed, 02 Oct 2024 10:30:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b6994a0-01c5-43b0-86fd-f85388565a5f</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you share your configuration?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You need to enable RSA for this to work:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY=y
CONFIG_PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT=y
CONFIG_PSA_WANT_RSA_KEY_SIZE_2048=y
CONFIG_MBEDTLS_RSA_C=y
CONFIG_MBEDTLS_HEAP_SIZE=81920&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>