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

UI/Fix node-forge EC error #13238

Merged
merged 12 commits into from
Nov 23, 2021
3 changes: 3 additions & 0 deletions changelog/13238.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Fixes node-forge error when parsing EC (elliptical curve) certs
```
9 changes: 8 additions & 1 deletion ui/app/helpers/parse-pki-cert.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ export function parsePkiCert([model]) {
if (!model.certificate) {
return;
}
const cert = pki.certificateFromPem(model.certificate);
let cert;
// node-forge cannot parse EC (elliptical curve) certs
// return original response if unable to convert a Forge cert from PEM
try {
cert = pki.certificateFromPem(model.certificate);
} catch (error) {
return model;
}
const commonName = cert.subject.getField('CN') ? cert.subject.getField('CN').value : null;
const issueDate = cert.validity.notBefore;
const expiryDate = cert.validity.notAfter;
Expand Down