Skip to content
This repository was archived by the owner on Dec 8, 2025. It is now read-only.
This repository was archived by the owner on Dec 8, 2025. It is now read-only.

HTTP request not working as expected, SSL error #607

Description

Tip: From Visual Studio Code, you can use the command DeviceScript: Report Issue... to prefill the issue template.

Describe the bug
From a ESP32 device, I want to post some data to a Cloud Firestore, thus I'm using fetch(...) function to achieve that.
The store is currently unprotected for the moment, so any data can be posted without much overhead.
Thing is, I get a socket tls://firestore.googleapis.com:443 error tls://firestore.googleapis.com:443: self-signed certificate.
This is my code:

const url = `https://firestore.googleapis.com/v1/projects/{PROJECT_ID}/databases/(default)/documents/{COLLECTION_ID}`
const options = {
    method: "POST",
    body: JSON.stringify(...),
    headers: { "Content-Type": "application/json", key: API_KEY }
}
const response = await fetch(url, options)
//...

NOTE: I tried exactly the same with MicroPython, and works like a charm.
Here is my python code:

import urequests
#...
response = urequests.post(
    f'https://firestore.googleapis.com/v1/projects/{PROJECT_ID}/databases/(default)/documents/{COLLECTION_ID}',
    json=data,
    headers={
        'Content-Type': 'application/json',
        'key': C.FIRESTORE_API_KEY
    },
)

So, how's this different from what I'm doing with MicroPython?

To Reproduce
Steps to reproduce the behavior:

  1. Connect device to WIFI access
  2. Make a fetch(...) request to Cloud Firestore
  3. Get SSL Self Signed Cert error
  4. Cry

Expected behavior
Be able to successfully make a request to Cloud Firestore.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Console Output:

VM> connecting to tls://firestore.googleapis.com:443
VM> socket tls://firestore.googleapis.com:443 open undefined
VM> req: POST /v1/projects/[PROJECT_ID]/databases/(default)/documents/sensors HTTP/1.1
VM> content-type: application/json
VM> key: [API_KEY]
VM> user-agent: DeviceScript fetch()
VM> accept: */*
VM> host: firestore.googleapis.com
VM> connection: close
VM> content-length: 2
VM>
VM> socket tls://firestore.googleapis.com:443 error tls://firestore.googleapis.com:443: self-signed certificate

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions