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

Update island.is certificate and checks #6

Merged
merged 1 commit into from
Jul 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions cert/FullgiltAudkenni.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
-----BEGIN CERTIFICATE-----
MIIFfDCCA2SgAwIBAgICAyQwDQYJKoZIhvcNAQELBQAwazELMAkGA1UEBhMCSVMx
EzARBgNVBAUTCjU1MDE2OTI4MjkxGjAYBgNVBAoTEUZqYXJtYWxhcmFkdW5leXRp
MRYwFAYDVQQLEw1Sb3RhcnNraWxyaWtpMRMwEQYDVQQDEwpJc2xhbmRzcm90MB4X
DTE3MTExNjEzMjgzM1oXDTMyMTExNjEzMjgzM1owfjELMAkGA1UEBhMCSVMxEzAR
BgNVBAUTCjUyMTAwMDI3OTAxFTATBgNVBAoTDEF1ZGtlbm5pIGhmLjEnMCUGA1UE
CxMeVXRnZWZhbmRpIGZ1bGxnaWxkcmEgc2tpbHJpa2phMRowGAYDVQQDExFGdWxs
Z2lsdCBhdWRrZW5uaTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMyn
5tktN9C5QTrErtjS5YM+0k29pTy5a8TYl56Ma70OJT6aO17z5NsPjwSnTswlEZ34
+zjzZm5MVxi8/fQpbDZlE/4N4YZlYBD1rm8AZB3mJUyPVNYQpTirnWPAIXUjYD0B
25K7NU6V7MTibr5Z0VRgljvSbaKut4Y2ld3bx6Kmzc4pHKLU2hjbK+BSrPTbKuLH
8Xae9WP6O2Zxd2d3elDUmh+0uhFexf3DuBNxvp4ildmISdDG2x538i+jBOUyv9GX
wwbPGadt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9ZGnbMLM+j84LDpT0rFMLNkegD
FVob63pewil6mH43mVOLq6tyYMiU7mgzYcui1rGnhtLiSqpI6L1UaQ2IqT4PJGdX
PIeO6oWVJpZaF7hWABD7sw==
-----END CERTIFICATE-----
36 changes: 0 additions & 36 deletions cert/TrausturBunadur.pem

This file was deleted.

14 changes: 7 additions & 7 deletions src/validateSignature.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function isCertificateDataValid(cert) {
const { organizationName } = cert.issuer;
const { validFrom, validTo } = cert;

if (serialName !== "6503760649" || organizationName !== "Audkenni ehf.") {
if (serialName !== "6503760649" || organizationName !== "Audkenni hf.") {
return false;
}

Expand Down Expand Up @@ -62,17 +62,17 @@ function checkSignature(doc, pem, xml) {

function isCertificateValid(certificate) {
// Reference: https://www.audkenni.is/adstod/skilriki-kortum/skilrikjakedjur/
const TrausturBunadur = Certificate.fromPEM(
readFileSync(path.resolve(__dirname, "../cert/TrausturBunadur.pem"))
const certFromPem = Certificate.fromPEM(
readFileSync(path.resolve(__dirname, "../cert/FullgiltAudkenni.pem"))
);

// we only need to verify TrausturBunadur cert because that is the cert used
// we only need to verify the authority cert because that is the cert used
// to sign the message from Island.is
if (
TrausturBunadur.verifySubjectKeyIdentifier() &&
certFromPem.verifySubjectKeyIdentifier() &&
certificate.verifySubjectKeyIdentifier() &&
TrausturBunadur.checkSignature(certificate) === null &&
certificate.isIssuer(TrausturBunadur)
certFromPem.checkSignature(certificate) === null &&
certificate.isIssuer(certFromPem)
) {
return true;
}
Expand Down