how to connect firebase with libcurl

0

I want to connect my code to firebase with using libcurl library and read datas i have function like this

static size_t my_write(void* buffer, size_t size, size_t nmemb, void* param) {
  std::string& text = *static_cast<std::string*>(param);
  size_t totalsize = size * nmemb;
  text.append(static_cast<char*>(buffer), totalsize);
  return totalsize;
}

and I have main function such as

int main() {



std::string result;
CURL* curl;
CURLcode res;

curl_global_init(CURL_GLOBAL_DEFAULT);

curl = curl_easy_init();
if (curl) {
    curl_easy_setopt(curl,CURLOPT_URL,"https://example-project-62811-default-rtdb.firebaseio.com/.json");

    curl_easy_setopt(curl, CURLOPT_PROXY_SSL_OPTIONS, CURLSSLOPT_ALLOW_BEAST |
        CURLSSLOPT_NO_REVOKE);
    
    curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,my_write);
    curl_easy_setopt(curl,CURLOPT_WRITEDATA, &result);

    curl_easy_setopt(curl,CURLOPT_VERBOSE, 1L);

    res = curl_easy_perform(curl);

    curl_easy_cleanup(curl);

    if (CURLE_OK != res) {
        std::cerr << "CURL ERROR: " << res << "\n";
    }

}
curl_global_cleanup();

std::cout << result << "\n\n";
}

the code is working fine on other apis like https://api.chucknorris.io and the error that i get for trying to connect firebase is

  • Trying 35.201.97.85:443...
  • Connected to example-project-62811-default-rtdb.firebaseio.com (35.201.97.85) port 443 (#0)
  • schannel: next InitializeSecurityContext failed: Unknown error (0x80092013)
  • Closing connection 0
  • schannel: shutting down SSL/TLS connection with example-project-62811-default-rtdb.firebaseio.com port 443 CURL ERROR: 35

edit-1 i also tried to write run from command prompt and it gives me same error and when i add add --ssl-no-revoke to script it worked

curl https://example-project-62811-default-rtdb.firebaseio.com/.json --ssl-no-revoke

is working and then i tried to use this technique in my code

curl_easy_setopt(curl, CURLOPT_PROXY_SSL_OPTIONS, CURLSSLOPT_ALLOW_BEAST |
        CURLSSLOPT_NO_REVOKE);

but it didn't work how can i solve this problem ?

c++
curl
firebase-realtime-database
libcurl
wincrypt
asked on Stack Overflow Dec 29, 2020 by batuhansenoglu • edited Dec 29, 2020 by rustyx

1 Answer

0

Schannel error code 0x80092013 means Revocation Server Offline.

In your case the Firebase CRL, http://crl.pki.goog/GTS1O1.crl as specified in the server certificate, could not be fetched.

That could be due to a misconfiguration of the Windows trust store, DNS, firewall, proxy, corporate network, or alike.

As a temporary (insecure) solution, you can bypass CRL verification using

    curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE);

Notice the variable - CURLOPT_SSL_OPTIONS. The one you try CURLOPT_PROXY_SSL_OPTIONS is for proxy connections only.

answered on Stack Overflow Dec 29, 2020 by rustyx

User contributions licensed under CC BY-SA 3.0