This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cannot Connect to Googleapis.com

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 based off of the https_client sample.

I am able to connect to Skyhookwireless and UnwiredLabs and use their services to geolocate, but whenever I try to connect to Googleapis, the connect() function gives me one of the following errors:

#define  EOPNOTSUPP      95  /* Operation not supported on transport endpoint */
#define  ECONNREFUSED   111  /* Connection refused */

I considered that it might be a certificate issue so I attempted to use a certificate returned by openssl s_client www.googleapis.com:443. I was unable connect to google with that certificate, but I was able to connect to skyhook with it.

Any assistance would be much appreciated. 

Parents
  • Hi Jeremy,

    I also feel it is a certificate issue, but I do not quite understand your attempt.

    Like the HTPPS client sample, you need to replace the certificate in the samples/nrf9160/https_client/cert with the root CA used by google API in order to build HTTPS connection. I did not find a document specifically for IoT devices. You can find the introduction document and root CA resources from the following links provided by Google:

    Google Online Security Blog: Google, HTTPS, and device compatibility (googleblog.com)

    Google Trust Services | Repository (pki.goog)

    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.

    Best regards,

    Charlie

  • 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 EOPNOTSUPP 95 error. 

    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.


    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.

  • Here is how I reproduced my issue using the HTTPS_Client example:

    1) change the Host section in the HTTP_HEAD to www.googleapis.com:443
    #define HTTP_HEAD                                                              \
        "HEAD / HTTP/1.1\r\n"                                                  \
        "Host: www.googleapis.com:443\r\n"                                            \
        "Connection: close\r\n\r\n"
    2) use one of google's root certificates (I used the GTS R1 Root CA from the google trust services linked above).
    static const char cert[] = {
        #include "../cert/gtsr1.pem"
    };
    3) set getaddrinfo to use googleapis.com

        err = getaddrinfo("www.googleapis.com", NULL, &hints, &res);
        if (err) {
            printk("getaddrinfo() failed, err %d\n", errno);
            return;
        }

    4) run the program and get the "connect() failed, err: 95" error message.
    note: attached is the certificate I used.
Reply
  • Here is how I reproduced my issue using the HTTPS_Client example:

    1) change the Host section in the HTTP_HEAD to www.googleapis.com:443
    #define HTTP_HEAD                                                              \
        "HEAD / HTTP/1.1\r\n"                                                  \
        "Host: www.googleapis.com:443\r\n"                                            \
        "Connection: close\r\n\r\n"
    2) use one of google's root certificates (I used the GTS R1 Root CA from the google trust services linked above).
    static const char cert[] = {
        #include "../cert/gtsr1.pem"
    };
    3) set getaddrinfo to use googleapis.com

        err = getaddrinfo("www.googleapis.com", NULL, &hints, &res);
        if (err) {
            printk("getaddrinfo() failed, err %d\n", errno);
            return;
        }

    4) run the program and get the "connect() failed, err: 95" error message.
    note: attached is the certificate I used.
Children
No Data
Related