mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 08:27:36 +00:00
Update db schema, load cert from cert body instead
This commit is contained in:
@@ -12,6 +12,7 @@ export const PkiAcmeChallengesSchema = z.object({
|
|||||||
authId: z.string().uuid(),
|
authId: z.string().uuid(),
|
||||||
type: z.string(),
|
type: z.string(),
|
||||||
status: z.string(),
|
status: z.string(),
|
||||||
|
error: z.string().nullable().optional(),
|
||||||
validatedAt: z.date().nullable().optional(),
|
validatedAt: z.date().nullable().optional(),
|
||||||
createdAt: z.date(),
|
createdAt: z.date(),
|
||||||
updatedAt: z.date()
|
updatedAt: z.date()
|
||||||
|
|||||||
@@ -10,17 +10,15 @@ import { TImmutableDBKeys } from "./models";
|
|||||||
export const PkiAcmeOrdersSchema = z.object({
|
export const PkiAcmeOrdersSchema = z.object({
|
||||||
id: z.string().uuid(),
|
id: z.string().uuid(),
|
||||||
accountId: z.string().uuid(),
|
accountId: z.string().uuid(),
|
||||||
|
certificateId: z.string().uuid().nullable().optional(),
|
||||||
notBefore: z.date().nullable().optional(),
|
notBefore: z.date().nullable().optional(),
|
||||||
notAfter: z.date().nullable().optional(),
|
notAfter: z.date().nullable().optional(),
|
||||||
expiresAt: z.date(),
|
expiresAt: z.date(),
|
||||||
|
csr: z.string().nullable().optional(),
|
||||||
|
error: z.string().nullable().optional(),
|
||||||
status: z.string(),
|
status: z.string(),
|
||||||
createdAt: z.date(),
|
createdAt: z.date(),
|
||||||
updatedAt: z.date(),
|
updatedAt: z.date()
|
||||||
csr: z.string().nullable().optional(),
|
|
||||||
certificate: z.string().nullable().optional(),
|
|
||||||
certificateChain: z.string().nullable().optional(),
|
|
||||||
error: z.string().nullable().optional(),
|
|
||||||
certificateId: z.string().uuid().nullable().optional()
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TPkiAcmeOrders = z.infer<typeof PkiAcmeOrdersSchema>;
|
export type TPkiAcmeOrders = z.infer<typeof PkiAcmeOrdersSchema>;
|
||||||
|
|||||||
@@ -599,32 +599,27 @@ export const pkiAcmeServiceFactory = ({
|
|||||||
// TODO: this should be the same transaction?
|
// TODO: this should be the same transaction?
|
||||||
let errorToReturn: Error | undefined;
|
let errorToReturn: Error | undefined;
|
||||||
try {
|
try {
|
||||||
const { certificate, certificateChain, certificateId } =
|
const { certificateId } = await certificateV3Service.signCertificateFromProfile({
|
||||||
await certificateV3Service.signCertificateFromProfile({
|
actor: ActorType.ACME_ACCOUNT,
|
||||||
actor: ActorType.ACME_ACCOUNT,
|
actorId: accountId,
|
||||||
actorId: accountId,
|
actorAuthMethod: null,
|
||||||
actorAuthMethod: null,
|
actorOrgId,
|
||||||
actorOrgId,
|
profileId,
|
||||||
profileId,
|
csr,
|
||||||
csr,
|
notBefore: order.notBefore ? new Date(order.notBefore) : undefined,
|
||||||
notBefore: order.notBefore ? new Date(order.notBefore) : undefined,
|
notAfter: order.notAfter ? new Date(order.notAfter) : undefined,
|
||||||
notAfter: order.notAfter ? new Date(order.notAfter) : undefined,
|
validity: {
|
||||||
validity: {
|
// TODO: read config from the profile to get the expiration time instead
|
||||||
// TODO: read config from the profile to get the expiration time instead
|
ttl: (24 * 60 * 60 * 1000).toString()
|
||||||
ttl: (24 * 60 * 60 * 1000).toString()
|
},
|
||||||
},
|
enrollmentType: EnrollmentType.ACME
|
||||||
enrollmentType: EnrollmentType.ACME
|
});
|
||||||
});
|
|
||||||
// TODO: associate the certificate with the order
|
// TODO: associate the certificate with the order
|
||||||
await acmeOrderDAL.updateById(
|
await acmeOrderDAL.updateById(
|
||||||
orderId,
|
orderId,
|
||||||
{
|
{
|
||||||
status: AcmeOrderStatus.Valid,
|
status: AcmeOrderStatus.Valid,
|
||||||
csr,
|
csr,
|
||||||
// TODO: we actually don't need to store the certificate and certificate chain here
|
|
||||||
// It appears that the certificate and certificate chain are stored in the certificate_body table already
|
|
||||||
certificateChain,
|
|
||||||
certificate,
|
|
||||||
certificateId
|
certificateId
|
||||||
},
|
},
|
||||||
tx
|
tx
|
||||||
|
|||||||
Reference in New Issue
Block a user