Coder Social home page Coder Social logo

tibordp / eudcc-validator Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 1.0 442 KB

Validator app for EU Digital Covid Certificates

Home Page: https://eudcc.ojdip.net

License: MIT License

HTML 4.89% CSS 0.35% JavaScript 94.54% Shell 0.22%
digital-covid-certificate pwa eudcc react material-ui-react

eudcc-validator's People

Contributors

tibordp avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

joelsilver

eudcc-validator's Issues

Key identifier not read correctly

I tested your validator with my personal certificate and got the error that "The DCC is not in a supported format, so the validity cannot be verified." This issue comes from the fact that your code assumes the kid is located in the protected part of the WebToken. In my case the kid is located in the unprotected part.

The spec says: "The Key Identifier is not a security-critical field. For this reason, it MAY also be placed in an unprotected header if required. Verifiers MUST accept both options. If both options are present, the Key Identifier in the protected header MUST be used."

A simple change to make it work would be:

diff --git a/src/decode.js b/src/decode.js
index 534ce57..512fdc8 100644
--- a/src/decode.js
+++ b/src/decode.js
@@ -59,9 +59,11 @@ export const decodeEudcc = async (data, trustList) => {
       // Try to extract KID from the certificate, if it is not present,
       // we will not be able to validate the signature, but we can still
       // display the data. We only target version 1.3.0+ of the spec.
-      const signatureInfo = cbor.decodeFirstSync(decoded.value[0]);
+      const signatureInfo_protected = cbor.decodeFirstSync(decoded.value[0]);
+      const signatureInfo_unprotected = decoded.value[1];
       kid = Buffer.from(
-        signatureInfo.get(cose.common.HeaderParameters.kid)
+        signatureInfo_protected.get(cose.common.HeaderParameters.kid) ||
+        signatureInfo_unprotected.get(cose.common.HeaderParameters.kid)
       ).toString("base64");
     } catch (e) {
       return { data: hcert, error: "UNSUPPORTED_FORMAT" };

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.