next-lucia-auth: SSL wrong version number.

Greetings, I have an issue on my local build for development where i cannot get the application to properly connect to the DB because of a SSL issue.

I keep getting this issue at:

 ⨯ TypeError: fetch failed
    at async login (./src/lib/auth/actions.ts:64:26)
Cause: [Error: 00F88DA8327F0000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:354:
] {
  library: 'SSL routines',
  reason: 'wrong version number',
  code: 'ERR_SSL_WRONG_VERSION_NUMBER'
}

Problem is, this is a completely fresh clone from github, the .env is the only edited part. How can i solve this error?

About this issue

  • Original URL
  • State: closed
  • Created 5 months ago
  • Comments: 16 (11 by maintainers)

Most upvoted comments

I will not add my changes, those changes are not reasonable. However Kinfish (the other contributor) found a much better solution, he uses pg drivers instead of mysql promise based drivers, i will look into that and if it works i will open a pr with that solution for you to view.

My edits are too dramatic for something so simple.

@iamtouha I got a workaround, although it is most likely not ideal for use with this project. Primarily because it has a lot of changes.

My current drizzle index code looks like this:

/*
import { drizzle } from "drizzle-orm/planetscale-serverless";
import { Connection } from "@planetscale/database";

import { env } from "@/env";
import * as schema from "./schema";

export const connection = new Connection({ url: env.DATABASE_URL });

export const db = drizzle(connection, { schema });
*/ 
import { drizzle } from "drizzle-orm/mysql2";
import mysql from "mysql2/promise";

import { env } from "@/env";
import * as schema from "./schema";

async function connect() {
    const connection = await mysql.createConnection({
        host: "127.0.0.1",
        user: "MariaInterface",
        password: "MARIADB",
        port: 3306,
        database: "lucia",
    });

    const db = drizzle(connection, {schema, mode: "planetscale"})
    return db
}

export const udb = connect();

This solves the conncetionissues, however i don’t know if this would work to connect to planetscale but i can take a look into it. (SSL errors, cannot check myself)

However, now i have to go through all the code that imports db and await it. But it does solve my issue(s)

Do note that this should not be used, at least not here considering i don’t know if this is compatible with planetscale or other devices, all i know is that this works for me. + i made plenty more changes in:

  • auth/actions
  • auth/index
  • auth/validate-request And more!

Alright, i have reverted to the code that was posted. I use node 20.9.0, i am aware that newer versions are available but right now i doubt it’s relevant. I think you meant compilerOptions.target, to answer, it’s currently set at “es2022”.

I also thought a bit about it, but it could be that the connection still fails but we don’t know that because the code running fails before the connection even happens, i will have to check mysql logs if i want to know if the app even connects.