tursodatabase/libsql-client-ts

TLS Error - Can't connect to URL

indrazm opened this issue · 2 comments

Hey,
I have this issue, not sure what's wrong.

2024-06-09 21:03:18 Bun v1.1.12 (Linux x64 baseline)
2024-06-09 21:06:24 70 |       } else if (opts.authToken) {
2024-06-09 21:06:24 71 |           authToken = opts.authToken;
2024-06-09 21:06:24 72 |       }
2024-06-09 21:06:24 73 |       const encryptionKey = opts?.encryptionKey ?? "";
2024-06-09 21:06:24 74 |       const syncPeriod = opts?.syncPeriod ?? 0.0;
2024-06-09 21:06:24 75 |       this.db = databaseOpenWithRpcSync(path, opts.syncUrl, authToken, encryptionCipher, encryptionKey, syncPeriod);
2024-06-09 21:06:24                      ^
2024-06-09 21:06:24 error: TLS error: no valid native root CA certificates found (0 invalid)
2024-06-09 21:06:24       at new Database (/app/node_modules/libsql/index.js:75:17)
2024-06-09 21:06:24       at _createClient (/app/node_modules/@libsql/client/lib-esm/sqlite3.js:39:16)
2024-06-09 21:06:24       at /app/src/utils/client.ts:3:23
2024-06-09 21:06:24 
2024-06-09 21:06:24 Bun v1.1.12 (Linux x64 baseline)

Here is my code :

export const client = createClient({
  url: "file:./db/dev.db",
  syncUrl: process.env.TURSODB_URL!,
  authToken: process.env.TURSODB_AUTH_TOKEN!,
  syncInterval: 60 * 5,
});

It works on Development, but it's not working on Production (Docker).
Anyone have the same issue ?

Thanks in Advance!

@indrazm How did you resolve this?

Hey @erkannt By adding the Certificate into the Docker!
Have a look.

FROM oven/bun

WORKDIR /app

COPY package.json .
COPY bun.lockb .
COPY src src

RUN bun install --production

# This one below is fixing the issue
RUN apt-get update && apt-get install -y ca-certificates

CMD ["bun", "src/index.ts"]

EXPOSE 3000