mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-13 16:22:39 +10:00
ability to fetch client certs for p2p
This commit is contained in:
24
server/api/v1/client/http/fetch.get.ts
Normal file
24
server/api/v1/client/http/fetch.get.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
|
||||
export default defineClientEventHandler(async (h3) => {
|
||||
const query = getQuery(h3);
|
||||
const clientId = query.id?.toString();
|
||||
if (!clientId)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Missing id in query",
|
||||
});
|
||||
|
||||
const certificate = await h3.context.ca.fetchClientCertificate(clientId);
|
||||
if (!certificate) {
|
||||
// Either it doesn't exist or it's blacklisted
|
||||
throw createError({
|
||||
statusCode: 401,
|
||||
statusMessage: "Invalid or blacklisted clientId",
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
certificate: certificate.cert,
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user