Ensure client certificate is uploaded as a file (#4382)
This commit is contained in:
parent
a77d5705dc
commit
3bfbf70ada
3 changed files with 9 additions and 5 deletions
|
@ -93,9 +93,11 @@ export const Keys = ({ clientId, save, hasConfigureAccess }: KeysProps) => {
|
|||
try {
|
||||
const formData = new FormData();
|
||||
const { file, ...rest } = importFile;
|
||||
Object.entries(rest).map((entry) =>
|
||||
formData.append(entry[0], entry[1] as string)
|
||||
);
|
||||
|
||||
for (const [key, value] of Object.entries(rest)) {
|
||||
formData.append(key, value);
|
||||
}
|
||||
|
||||
formData.append("file", file.value!);
|
||||
|
||||
await adminClient.clients.uploadCertificate(
|
||||
|
|
|
@ -209,6 +209,8 @@ export class Agent {
|
|||
} else if (requestHeaders.get("content-type") === "text/plain") {
|
||||
// Pass the payload as a plain string if the content type is 'text/plain'.
|
||||
requestOptions.body = payload as unknown as string;
|
||||
} else if (payload instanceof FormData) {
|
||||
requestOptions.body = payload;
|
||||
} else {
|
||||
// Otherwise assume it's JSON and stringify it.
|
||||
requestOptions.body = JSON.stringify(
|
||||
|
@ -216,7 +218,7 @@ export class Agent {
|
|||
);
|
||||
}
|
||||
|
||||
if (!requestHeaders.has("content-type")) {
|
||||
if (!requestHeaders.has("content-type") && !(payload instanceof FormData)) {
|
||||
requestHeaders.set("content-type", "application/json");
|
||||
}
|
||||
|
||||
|
|
|
@ -987,7 +987,7 @@ export class Clients extends Resource<{ realm?: string }> {
|
|||
|
||||
public uploadCertificate = this.makeUpdateRequest<
|
||||
{ id: string; attr: string },
|
||||
any
|
||||
FormData
|
||||
>({
|
||||
method: "POST",
|
||||
path: "/{id}/certificates/{attr}/upload-certificate",
|
||||
|
|
Loading…
Reference in a new issue