<?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 Connect to Googleapis.com</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/84322/cannot-connect-to-googleapis-com</link><description>Hello, 
 I am trying to use googleapis.com to perform cell and wifi geolocation and am having trouble connecting. 
 I am using a custom board with a nRF9160 chip and the 1.6.1 version of the sdk. The latest VS Code pack is my IDE/compiler. 
 My code is</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 09 Feb 2022 14:41:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/84322/cannot-connect-to-googleapis-com" /><item><title>RE: Cannot Connect to Googleapis.com</title><link>https://devzone.nordicsemi.com/thread/352110?ContentTypeID=1</link><pubDate>Wed, 09 Feb 2022 14:41:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b67253f-957f-4061-88ce-17f574edf92c</guid><dc:creator>Charlie</dc:creator><description>&lt;p&gt;Hi Jeremy,&lt;/p&gt;
&lt;p&gt;I did some tests on my device and it works without issue. Here are some key points:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;GTS Root R1 Root CA from &lt;a title="https://pki.goog/repository/" href="https://pki.goog/repository/" rel="noopener noreferrer" target="_blank"&gt;Google Trust Services | Repository (pki.goog)&lt;/a&gt;&amp;nbsp;is the correct choice.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;You POST request format should be correct like the following example, also pay attention when you need to add data to the body.&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define HTTP_HEAD  \
	&amp;quot;POST /geolocation/v1/geolocate?key=AIzaSyDTWlOdSDqsIp9txDnIqzD9UFBKe8xcmfs HTTP/1.1\r\n&amp;quot;\
	&amp;quot;Host: www.googleapis.com\r\n&amp;quot;  \
	&amp;quot;Content-Length: 0\r\n&amp;quot;  \
	&amp;quot;Connection: close\r\n\r\n&amp;quot;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can test with the attached project file and remember to replace the API key with your own and enable the Geolocation service(&lt;a href="https://console.cloud.google.com/apis)"&gt;https://console.cloud.google.com/apis)&lt;/a&gt;. You will get something like this from the printout:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;2022-02-09T14:27:42.878Z DEBUG modem &amp;lt;&amp;lt; *** Booting Zephyr OS build v2.7.0-ncs1  ***
2022-02-09T14:27:42.884Z DEBUG modem &amp;lt;&amp;lt; HTTPS client sample started
2022-02-09T14:27:42.952Z DEBUG modem &amp;lt;&amp;lt; Certificate match
2022-02-09T14:27:44.584Z DEBUG modem &amp;lt;&amp;lt; Waiting for network.. OK
2022-02-09T14:27:44.658Z DEBUG modem &amp;lt;&amp;lt; Connecting to www.googleapis.com
2022-02-09T14:27:46.568Z DEBUG modem &amp;lt;&amp;lt; Sent 151 bytes
2022-02-09T14:27:46.783Z DEBUG modem &amp;lt;&amp;lt; Received 661 bytes
2022-02-09T14:27:46.786Z DEBUG modem &amp;lt;&amp;lt; HTTP/1.1 200 OK
2022-02-09T14:27:46.793Z DEBUG modem &amp;lt;&amp;lt; Content-Type: application/json; charset=UTF-8
2022-02-09T14:27:46.794Z DEBUG modem &amp;lt;&amp;lt; Vary: X-Origin
2022-02-09T14:27:46.794Z DEBUG modem &amp;lt;&amp;lt; Vary: Referer
2022-02-09T14:27:46.795Z DEBUG modem &amp;lt;&amp;lt; Date: Wed, 09 Feb 2022 14:27:46 GMT
2022-02-09T14:27:46.798Z DEBUG modem &amp;lt;&amp;lt; Server: scaffolding on HTTPServer2
2022-02-09T14:27:46.800Z DEBUG modem &amp;lt;&amp;lt; Cache-Control: private
2022-02-09T14:27:46.801Z DEBUG modem &amp;lt;&amp;lt; X-XSS-Protection: 0
2022-02-09T14:27:46.804Z DEBUG modem &amp;lt;&amp;lt; X-Frame-Options: SAMEORIGIN
2022-02-09T14:27:46.812Z DEBUG modem &amp;lt;&amp;lt; X-Content-Type-Options: nosniff
2022-02-09T14:27:46.827Z DEBUG modem &amp;lt;&amp;lt; Alt-Svc: h3=&amp;quot;:443&amp;quot;; ma=2592000,h3-29=&amp;quot;:443&amp;quot;; ma=2592000,h3-Q050=&amp;quot;:443&amp;quot;; ma=2592000,h3-Q046=&amp;quot;:443&amp;quot;; ma=2592000,h3-Q043=&amp;quot;:443&amp;quot;; ma=2592000,quic=&amp;quot;:443&amp;quot;; ma=2592000; v=&amp;quot;46,43&amp;quot;
2022-02-09T14:27:46.828Z DEBUG modem &amp;lt;&amp;lt; Accept-Ranges: none
2022-02-09T14:27:46.829Z DEBUG modem &amp;lt;&amp;lt; Vary: Origin,Accept-Encoding
2022-02-09T14:27:46.830Z DEBUG modem &amp;lt;&amp;lt; Connection: close
2022-02-09T14:27:46.832Z DEBUG modem &amp;lt;&amp;lt; Transfer-Encoding: chunked
2022-02-09T14:27:46.833Z DEBUG modem &amp;lt;&amp;lt; 66
2022-02-09T14:27:46.833Z DEBUG modem &amp;lt;&amp;lt; {
2022-02-09T14:27:46.834Z DEBUG modem &amp;lt;&amp;lt;   &amp;quot;location&amp;quot;: {
2022-02-09T14:27:46.836Z DEBUG modem &amp;lt;&amp;lt;     &amp;quot;lat&amp;quot;: xx.0389059,
2022-02-09T14:27:46.844Z DEBUG modem &amp;lt;&amp;lt;     &amp;quot;lng&amp;quot;: xx.7253719
2022-02-09T14:27:46.846Z DEBUG modem &amp;lt;&amp;lt;   },
2022-02-09T14:27:46.847Z DEBUG modem &amp;lt;&amp;lt;   &amp;quot;accuracy&amp;quot;: 96092.638112573768
2022-02-09T14:27:46.848Z DEBUG modem &amp;lt;&amp;lt; }
2022-02-09T14:27:46.849Z DEBUG modem &amp;lt;&amp;lt; 0
2022-02-09T14:27:46.850Z DEBUG modem &amp;lt;&amp;lt; &amp;gt; HTTP/1.1 200 OK
2022-02-09T14:27:46.851Z DEBUG modem &amp;lt;&amp;lt; Finished, closing socket.&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ncs180_5F00_nrf9160_5F00_https_5F00_client_5F00_googleapis.zip"&gt;devzone.nordicsemi.com/.../ncs180_5F00_nrf9160_5F00_https_5F00_client_5F00_googleapis.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Charlie&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot Connect to Googleapis.com</title><link>https://devzone.nordicsemi.com/thread/351910?ContentTypeID=1</link><pubDate>Tue, 08 Feb 2022 17:06:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb0f421a-10de-4f88-820c-0994ae7a87ba</guid><dc:creator>jdorn</dc:creator><description>&lt;p&gt;Also, I have tested the google API using a program on my PC called Postman and was able to do so without any issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot Connect to Googleapis.com</title><link>https://devzone.nordicsemi.com/thread/351642?ContentTypeID=1</link><pubDate>Mon, 07 Feb 2022 20:51:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50fb4cbf-7fdc-40ed-9c0c-c038980a4791</guid><dc:creator>jdorn</dc:creator><description>&lt;p&gt;Here is how I reproduced my issue using the HTTPS_Client example:&lt;/p&gt;
&lt;div&gt;1) change the Host section in the HTTP_HEAD to&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.googleapis.com:443/" rel="noopener noreferrer" target="_blank"&gt;www.googleapis.com:443&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define HTTP_HEAD                                                              \
    &amp;quot;HEAD / HTTP/1.1\r\n&amp;quot;                                                  \
    &amp;quot;Host: www.googleapis.com:443\r\n&amp;quot;                                            \
    &amp;quot;Connection: close\r\n\r\n&amp;quot;&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;2) use one of google&amp;#39;s root certificates (I used the GTS R1 Root CA from the google trust services linked above).&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="text"&gt;static const char cert[] = {
    #include &amp;quot;../cert/gtsr1.pem&amp;quot;
};&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;3) set getaddrinfo to use&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://googleapis.com/" rel="noopener noreferrer" target="_blank"&gt;googleapis.com&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    err = getaddrinfo(&amp;quot;www.googleapis.com&amp;quot;, NULL, &amp;amp;hints, &amp;amp;res);
    if (err) {
        printk(&amp;quot;getaddrinfo() failed, err %d\n&amp;quot;, errno);
        return;
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;4) run the program and get the &amp;quot;&lt;span&gt;connect() failed, err: 95&lt;/span&gt;&amp;quot; error message.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;note: attached is the certificate I used.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/gtsr1.zip"&gt;devzone.nordicsemi.com/.../gtsr1.zip&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot Connect to Googleapis.com</title><link>https://devzone.nordicsemi.com/thread/351409?ContentTypeID=1</link><pubDate>Fri, 04 Feb 2022 21:45:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6eb1c60f-b3f6-4e40-8735-5d01d1df3ed6</guid><dc:creator>jdorn</dc:creator><description>&lt;p&gt;I have attempted half a dozen different certificates from the source you linked (from different levels and of different types), and none of them worked. all gave the&amp;nbsp;EOPNOTSUPP 95 error.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I (again) was able to use some (all of the ones I tested) of them to connect to Skyhook, so I know I loaded them onto my device successfully.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I am not at the point of using their REST API, but I am fully confident in my ability to do so once I can connect to the website.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot Connect to Googleapis.com</title><link>https://devzone.nordicsemi.com/thread/351195?ContentTypeID=1</link><pubDate>Thu, 03 Feb 2022 16:21:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b076f42-3d29-4727-bdf9-c375f692f459</guid><dc:creator>Charlie</dc:creator><description>&lt;p&gt;Hi Jeremy,&lt;/p&gt;
&lt;p&gt;I also feel it is a certificate issue, but I do not quite understand your attempt.&lt;/p&gt;
&lt;p&gt;Like the HTPPS client sample, you need to replace&lt;span&gt;&amp;nbsp;the&amp;nbsp;certificate in the&amp;nbsp;&lt;/span&gt;&lt;code&gt;&lt;span&gt;samples/nrf9160/https_client/cert&lt;/span&gt;&lt;/code&gt;&amp;nbsp;with the root CA used by google API in order to build HTTPS connection. I did not find a document&amp;nbsp;specifically for IoT devices. You can find the introduction document and root CA resources from the following links provided by Google:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://security.googleblog.com/2021/03/google-https-and-device-compatibility.html"&gt;Google Online Security Blog: Google, HTTPS, and device compatibility (googleblog.com)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://pki.goog/repository/"&gt;Google Trust Services | Repository (pki.goog)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I also suggest you play the API on PC first to make sure it works, it is much easier to debug on nRF9160 when you get familiar with the API.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Charlie&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>