Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support self signed certificate #2915

Closed
rvitorgomes opened this issue May 17, 2023 · 13 comments · Fixed by #3457
Closed

Support self signed certificate #2915

rvitorgomes opened this issue May 17, 2023 · 13 comments · Fixed by #3457
Labels
enhancement New feature or request

Comments

@rvitorgomes
Copy link

What is the problem this feature would solve?

I'm trying to use edgedb javascript client (edgeql-js) but it fails to connect to my local edge server.

error: network error: DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate
code: "4278256384"

Version:
"edgedb": "^1.2.2",
"bun": "0.6.1",

My code:

import { Elysia } from 'elysia'
import { createClient } from "edgedb"

const client = createClient({
   // dsn: "edgedb://edgedb@localhost:5656/edgedb"
})
await client.ensureConnected()

const app = new Elysia()
   .get('/', () => 'Hello Elysia 2')
   .get('/e', async () => {
       return await client.query("select 2 + 2");
   })
   .listen(3000)

console.log(`🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`)

The error:

image

What is the feature you are proposing to solve the problem?

Seems to be a network package missing feature.

What alternatives have you considered?

No response

@rvitorgomes rvitorgomes added the enhancement New feature or request label May 17, 2023
@t0xicCode
Copy link

This seems more like an EdgeDB issue: https://www.edgedb.com/docs/reference/connection#granular-parameters
It provides a method to disable certificate validation, which would allow it to accept self-signed certificates.

@rvitorgomes
Copy link
Author

rvitorgomes commented May 19, 2023

Update:
I ran node with the same code and worked
Also tried disable all security, but it still shows an error.
The server doesn't support the edgedb-binary protocol

export const client = createClient({
   tlsSecurity: "insecure" 
});

What I'm trying to reason now is about their "binary protocol" has something that is missing....
I run node with the same code and worked

https://www.edgedb.com/docs/reference/protocol/index

@cirospaciari
Copy link
Collaborator

@rvitorgomes Boa tarde, poderia fazer um teste versão v0.6.3? foram feitas algumas melhorias, talvez funcione agora.

@rvitorgomes
Copy link
Author

Tried with this example:

// example.ts
const e = require('edgedb');

(async () => {
    const client = e.createClient({ 
    });
    const res = await client.query("select 2 + 2");
    process.stdout.write(res.toString());
    process.stdout.write('\n');
})();

In node v17:.
ts-node example.ts

image

In bun v0.6.3
bun example.ts
image

@e3dio
Copy link
Contributor

e3dio commented May 23, 2023

I actually had this issue earlier today with MongoDB. Confirm working correctly now in v0.6.3

@rvitorgomes
Copy link
Author

rvitorgomes commented May 23, 2023

I actually had this issue earlier today with MongoDB. Confirm working correctly now in v0.6.3

I'm sure it's on 0.6.3

image

I still think something about EdgeDB communication that bun still don't have fully implemented...

@e3dio
Copy link
Contributor

e3dio commented May 23, 2023

Your error looks different, my issue that was fixed was: error: SELF_SIGNED_CERT_IN_CHAIN when trying to connect to MongoDB Atlas from AWS EC2

@rvitorgomes
Copy link
Author

rvitorgomes commented May 23, 2023

// example.ts
import {createClient, createHttpClient} from 'edgedb';

const client = createHttpClient({
    instanceName: "edgedb_demo"
});
client.ensureConnected()

const res = await client.query("select 2 + 2")

console.log("Hello via Bun!", res);

Here it works properly, using the http communication,

@cirospaciari
Copy link
Collaborator

cirospaciari commented May 23, 2023

Probably it's some tls feature missing or diverging, we will investigate further, thanks for reporting.

@rvitorgomes
Copy link
Author

Your error looks different, my issue that was fixed was: error: SELF_SIGNED_CERT_IN_CHAIN when trying to connect to MongoDB Atlas from AWS EC2

Yeah, I think it also was fixed and another error apeared...maybe I'll check the versions error diff later.

@rvitorgomes
Copy link
Author

rvitorgomes commented Jun 3, 2023

Retried with 0.6.7, same.
Any updates? @cirospaciari

@cirospaciari
Copy link
Collaborator

cirospaciari commented Jun 3, 2023

Retried with 0.6.7, same.
Any updates? @cirospaciari

Not yet but soon will be, working on adding more features on TLS

@MrFoxPro
Copy link

MrFoxPro commented Nov 1, 2023

Sorry, but was this resolved? I still get this error on Bun 1.0.7

2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | exports.prettyPrintError = exports.EdgeDBError = void 0;
4 | const buffer_1 = require("../primitives/buffer");
5 | class EdgeDBError extends Error {
6 |     constructor(message, options) {
7 |         super(undefined, options);
            ^
error: network error: ECONNREFUSED: Failed to connect
 code: "4278256384"

      at new EdgeDBError (/home/foxpro/craft/sferadel/dev/api/node_modules/.pnpm/edgedb@1.4.0/node_modules/edgedb/dist/errors/base.js:7:8)
      at new ClientError (:1:32)
      at new ClientConnectionError (:1:32)
      at new ClientConnectionClosedError (:1:32)
      at _onError (/home/foxpro/craft/sferadel/dev/api/node_modules/.pnpm/edgedb@1.4.0/node_modules/edgedb/dist/rawConn.js:146:23)
      at node:net:331:34
      at processTicksAndRejections (:61:76)
      ```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants