export type GetApiV1CaSubjectDnCertificateDownloadArgs = {subject_dn: string}; export type GetApiV1CaSubjectDnCertificateDownloadOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get PEM file with the active CA certificate chain * * GET /v1/ca/{subject_dn}/certificate/download */ export const getApiV1CaSubjectDnCertificateDownload = async (args: GetApiV1CaSubjectDnCertificateDownloadArgs, options: GetApiV1CaSubjectDnCertificateDownloadOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") const url = `${baseUrl.replace(/\/+$/, '')}/v1/ca/${encodeURIComponent(String(args.subject_dn))}/certificate/download${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };