<?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>HTTP(S) TLS Example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/52315/http-s-tls-example</link><description>Hi, 
 I have an application that does HTTP requests to a backend server. I&amp;#39;m now working on implementing TLS for encryption of the data. 
 
 Are there any examples of doing HTTPS over secure sockets? Any help would be greatly appreciated. 
 
 - Jack</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 24 Sep 2019 12:51:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/52315/http-s-tls-example" /><item><title>RE: HTTP(S) TLS Example</title><link>https://devzone.nordicsemi.com/thread/211547?ContentTypeID=1</link><pubDate>Tue, 24 Sep 2019 12:51:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:585bc692-5427-4c8f-b9f2-ef28fb8dff22</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Can I see the rest of your code and .conf?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HTTP(S) TLS Example</title><link>https://devzone.nordicsemi.com/thread/210767?ContentTypeID=1</link><pubDate>Thu, 19 Sep 2019 16:03:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d3e7dc9-5c8e-4fe7-8c7e-b8002df45579</guid><dc:creator>Jack Panetta</dc:creator><description>&lt;p&gt;I have been using the http_download_client as a reference so far.&lt;/p&gt;
&lt;p&gt;I have a self-signed certificate that I generated using OpenSSL. I have that certificate uploaded to my server and have tested with Postman and am successfully able to make HTTP requests with that certificate.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m loading the .crt file and the .key file as follows:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static char certificate[] = {
    &amp;quot;-----BEGIN CERTIFICATE-----\n&amp;quot;
    &amp;quot;     private certificate   \n&amp;quot;
    &amp;quot;-----END CERTIFICATE-----\n&amp;quot;
};

static char private_key[] = {
    &amp;quot;-----BEGIN PRIVATE KEY-----\n&amp;quot;
    &amp;quot;       private key         \n&amp;quot;
    &amp;quot;-----END PRIVATE KEY-----\n&amp;quot;
};

// Provision certificates before modem power on

for (nrf_key_mgnt_cred_type_t type = 0; type &amp;lt; 5; type++) {
    err = nrf_inbuilt_key_delete(sec_tag, type);
    if (err) {
        printf(&amp;quot;Error deleting sec_tag type: %d; err: %d\n&amp;quot;, type, err);
    }
}

err = nrf_inbuilt_key_write(sec_tag, NRF_KEY_MGMT_CRED_TYPE_PUBLIC_CERT, certificate, strlen(certificate));
    if (err) {
        printf(&amp;quot;Error writing certificate: %d\n&amp;quot;, err);
        return -1;
    }
    
err = nrf_inbuilt_key_write(sec_tag, NRF_KEY_MGMT_CRED_TYPE_PRIVATE_CERT, private_key, strlen(private_key));
    if (err) {
        printf(&amp;quot;Error writing private key: %d\n&amp;quot;, err);
        return -1;
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I get the following error when trying to connect the socket:&lt;/p&gt;
&lt;p&gt;Socket Connect Error: -1; Errno: 45;&lt;/p&gt;
&lt;p&gt;Errno = 45 corresponds to&amp;nbsp;NRF_EOPNOTSUPP. Looking at the Zephyr BSD Socket Library this error means &amp;quot;The socket is listening and cannot be connected.&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;UPDATE:: The server I am trying to hit is an Azure hosted VM. I downloaded the CA Certificate that Microsoft has provisioned for the server. When I include the CA Certificate the HTTPS request goes through. Is there any reason why a CA Certificate is required? Shouldn&amp;#39;t I be able to use my own self-signed certificate?&lt;/p&gt;
&lt;p&gt;Just wondering if this is a problem with my hosting environment or a limitation of the TLS implementation in the nRF-Connect-SDK.&lt;/p&gt;
&lt;p&gt;- Jack&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>