Skip to content

Commit

Permalink
updated logic for certificate upload
Browse files Browse the repository at this point in the history
  • Loading branch information
prskid1000 committed Dec 7, 2023
1 parent 716d3ae commit f588243
Show file tree
Hide file tree
Showing 2 changed files with 888 additions and 914 deletions.
27 changes: 16 additions & 11 deletions WebUI/src/components/CertificatesAdmin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
import FormCustom from "./FormCustom";
import TableCustom from "./TableCustom";
import CertificateEditor from "./CertificateEditor";
import Utils from "../utils";
import Swal from "sweetalert2";
var _ = require("lodash");
Expand Down Expand Up @@ -380,9 +379,10 @@ export default {
console.log("item.....", this.item);
var oFile = file;
console.log(file);
// filter for image files
var rFilter = /^(application\/x-x509-ca-cert|application\/x-pkcs12)$/i;
if (!rFilter.test(oFile.type)) {
// filter for certificate files
var rFilter = /\.(pem)$/i;
var fileName = oFile.name;
if (!rFilter.test(fileName)) {
alert("Error invalid file-type");
return;
}
Expand All @@ -395,13 +395,18 @@ export default {
oReader.onload = function (e) {
console.log("edit---->", e.target.result);
var PEM = e.target.result;
PEM = PEM.replace("-----BEGIN CERTIFICATE-----", "").replace(
"-----END CERTIFICATE-----",
""
);
PEM = PEM.replace(/[^A-Za-z0-9+/=]+/gm, "");
that.item.data = PEM;
that.changedCert();
try {
PEM = PEM.replace("-----BEGIN CERTIFICATE-----", "").replace(
"-----END CERTIFICATE-----","");
PEM = PEM.replace(/[^A-Za-z0-9+/=]+/gm, "");
that.item.data = PEM;
that.changedCert();
console.log("Read certificate successfully")
} catch (ex) {
console.log("Error reading certificate", ex)
alert("Error reading certificate");
return;
}
};
oReader.readAsText(oFile);
},
Expand Down
Loading

0 comments on commit f588243

Please sign in to comment.