A parser and validator for the EU Digital Green Certificate (dgc) a.k.a. greenpass 📲✅
Current limitations:
To install the latest version of dgc
, add this to your Cargo.toml:
toml
[dependencies]
dgc = "*"
This library tries to address 2 main use cases:
rust
let raw_certificate_data = "HC1:NCF:603A0T9WTWGSLKC..."; // all the raw certificate data (extracted from a QR code)
let certificate_container = dgc::decode(raw_certificate_data).expect("Cannot parse certificate data");
println!("{:#?}", certificate_container);
```rust
let rawcertificatedata = "HC1:NCF:603A0T9WTWGSLKC..."; // all the raw certificate data (extracted from a QR code)
// This is a X509 certificate that contains a Public Key
let signaturecertificate = "MIIDujCCAaKgAwIBAgIIKUgZWBL1pnMw...";
// Key ID of the Public Key embedded in the certificate above
let keyid: Vec
// We create a new Trustlist (container of "trusted" public keys) let mut trustlist = dgc::TrustList::default(); // We add the public key in the certificate to the trustlist trustlist .addkeyfromcertificate(&keyid, signature_certificate) .expect("Failed to add key from certificate");
// Now we can validate the signature (this returns) let (certificatecontainer, signaturevalidity) = dgc::validate(rawcertificatedata, &trustlist).expect("Cannot parse certificate data");
println!("{:#?}", &certificate_container);
// Checks the validity of the signature match signature_validity { dgc::SignatureValidity::Valid => println!("The certificate signature is Valid!"), e => println!("Could not validate the signature: {}", e), } ```
To get started using dgc
, see the examples
or the docs.
If you clone the repository locally, you can easily run the example files with:
bash
cargo run --example <name of example file>
Everyone is very welcome to contribute to this project. You can contribute just by submitting bugs or suggesting improvements by opening an issue on GitHub.
Licensed under MIT License. © Luciano Mammino.