Skip to content

Commit

Permalink
fix csr cn generation using utf8 encoding
Browse files Browse the repository at this point in the history
Signed-off-by: haritz <hsaizsierra@gmail.com>
  • Loading branch information
haritzsaiz committed Jan 22, 2025
1 parent fdd0041 commit 263e553
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
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

0 comments on commit 263e553

Please sign in to comment.