CEC-2281 Fix cert name
This commit is contained in:
@@ -75,11 +75,6 @@ const CreateForm = ({ onCreate, busy }) => {
|
||||
control={<Radio />}
|
||||
label="Charging"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value={CertTypes.Aftersales}
|
||||
control={<Radio />}
|
||||
label="Aftersales"
|
||||
/>
|
||||
</RadioGroup>
|
||||
<Button
|
||||
type="submit"
|
||||
|
||||
@@ -6,7 +6,12 @@ import useStyles from "../../useStyles";
|
||||
|
||||
const CertMimeType = "application/x-pem-file";
|
||||
|
||||
const DownloadCerts = ({ vin, publicCert, privateCert, onChangeView }) => {
|
||||
const DownloadCerts = ({
|
||||
commonName,
|
||||
publicCert,
|
||||
privateCert,
|
||||
onChangeView,
|
||||
}) => {
|
||||
const classes = useStyles();
|
||||
|
||||
const onNewCert = (event) => {
|
||||
@@ -21,14 +26,14 @@ const DownloadCerts = ({ vin, publicCert, privateCert, onChangeView }) => {
|
||||
<li>
|
||||
<DownloadFileLink
|
||||
data={publicCert}
|
||||
filename={`${vin}_cert.pem`}
|
||||
filename={`${commonName}_cert.pem`}
|
||||
mimetype={CertMimeType}
|
||||
/>
|
||||
</li>
|
||||
<li>
|
||||
<DownloadFileLink
|
||||
data={privateCert}
|
||||
filename={`${vin}_key.pem`}
|
||||
filename={`${commonName}_key.pem`}
|
||||
mimetype={CertMimeType}
|
||||
/>
|
||||
</li>
|
||||
|
||||
@@ -9,16 +9,16 @@ exports[`DownloadCerts Render 1`] = `
|
||||
<ul>
|
||||
<li>
|
||||
<a
|
||||
download="TESTVIN_cert.pem"
|
||||
download="undefined_cert.pem"
|
||||
>
|
||||
TESTVIN_cert.pem
|
||||
undefined_cert.pem
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
download="TESTVIN_key.pem"
|
||||
download="undefined_key.pem"
|
||||
>
|
||||
TESTVIN_key.pem
|
||||
undefined_key.pem
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -24,7 +24,7 @@ const MainForm = () => {
|
||||
const [view, setView] = useState(VIEW_FORM);
|
||||
const [pubCert, setPubCert] = useState(null);
|
||||
const [privCert, setPrivCert] = useState(null);
|
||||
const [vin, setVIN] = useState(null);
|
||||
const [commonName, setCommonName] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
setTitle("Create Certificate");
|
||||
@@ -46,19 +46,19 @@ const MainForm = () => {
|
||||
|
||||
setPubCert(result.public_key);
|
||||
setPrivCert(result.private_key);
|
||||
setVIN(data.vin);
|
||||
setMessage(`Created ${data.vin} certificate`);
|
||||
setCommonName(data.common_name);
|
||||
setMessage(`Created ${data.common_name} certificate`);
|
||||
setView(VIEW_DOWNLOAD);
|
||||
} catch (e) {
|
||||
setMessage(e.message);
|
||||
logger.warn(e.stack);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const onChangeView = () => {
|
||||
setPubCert(null);
|
||||
setPrivCert(null);
|
||||
setVIN(null);
|
||||
setCommonName(null);
|
||||
|
||||
setView(VIEW_FORM);
|
||||
};
|
||||
@@ -66,7 +66,7 @@ const MainForm = () => {
|
||||
if (view === VIEW_DOWNLOAD)
|
||||
return (
|
||||
<DownloadCerts
|
||||
vin={vin}
|
||||
commonName={commonName}
|
||||
publicCert={pubCert}
|
||||
privateCert={privCert}
|
||||
onChangeView={onChangeView}
|
||||
|
||||
Reference in New Issue
Block a user