Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix csr cn generation using utf8 encoding #53

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils/crypto/csr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const createCSR = async (keyPair: CryptoKeyPair, hashAlg: "SHA-1" | "SHA-
if (subjectProps[key]) {
pkcs10.subject.typesAndValues.push(new pkijs.AttributeTypeAndValue({
type: key,
value: new asn1js.PrintableString({ value: subjectProps[key] })
value: new asn1js.Utf8String({ value: subjectProps[key] })
}));
}
}
Expand Down
21 changes: 18 additions & 3 deletions src/views/CAs/IssuedCertificates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import PublishIcon from "@mui/icons-material/Publish";
import React, { useEffect, useState } from "react";
import RefreshIcon from "@mui/icons-material/Refresh";
import apicalls from "ducks/apicalls";
import { errorToString } from "ducks/services/api-client";

const queryableFields = [
{ key: "subject.common_name", title: "Common Name", operator: "contains" },
Expand Down Expand Up @@ -64,8 +65,12 @@ export const IssuedCertificates: React.FC<Props> = ({ caData }) => {
component: (
<CSRInBrowserGenerator onCreate={async (key, csr) => {
setImportSignStatus({ loading: true, errMessage: "", response: undefined });
const singResp = await apicalls.cas.signCertificateRequest(caData.id, window.window.btoa(csr));
setImportSignStatus({ loading: false, errMessage: "", response: singResp });
try {
const singResp = await apicalls.cas.signCertificateRequest(caData.id, window.window.btoa(csr));
setImportSignStatus({ loading: false, errMessage: "", response: singResp });
} catch (error: any) {
setImportSignStatus({ loading: false, errMessage: errorToString(error), response: undefined });
}
}} />
)
}, {
Expand Down Expand Up @@ -289,7 +294,17 @@ export const IssuedCertificates: React.FC<Props> = ({ caData }) => {
? (
importSignStatus.errMessage !== ""
? (
<>{importSignStatus.errMessage}</>
<Grid container spacing={2}>
<Grid xs={12}>
<Alert severity="error" action={
<Button variant="contained" color="error" size="small" onClick={() => { resetAddCertificate(); setDisplayIssueCert(false); }}>
Go Back
</Button>
}>
{importSignStatus.errMessage}
</Alert>
</Grid>
</Grid>
)
: (
importSignStatus.response !== undefined
Expand Down
Loading