-
-
Save yackermann/4c7850e53ba4a04cc9e000b41b8e6f8f to your computer and use it in GitHub Desktop.
const crypto = require('crypto'); | |
const base64url = require('base64url'); | |
const cbor = require('cbor'); | |
const jsrsasign = require('jsrsasign'); | |
let gsr2 = 'MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozps6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjNS7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CLTfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6CygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9iYWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG3lm0mi3f3BmGLjANBgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4GsJ0/WwbgcQ3izDJr86iw8bmEbTUsp9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu01yiPqFbQfXf5WRDLenVOavSot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG79G+dwfCMNYxdAfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg=='; | |
let hash = (alg, message) => { | |
return crypto.createHash(alg).update(message).digest(); | |
} | |
var getCertificateSubject = (certificate) => { | |
let subjectCert = new jsrsasign.X509(); | |
subjectCert.readCertPEM(certificate); | |
let subjectString = subjectCert.getSubjectString(); | |
let subjectFields = subjectString.slice(1).split('/'); | |
let fields = {}; | |
for(let field of subjectFields) { | |
let kv = field.split('='); | |
fields[kv[0]] = kv[1]; | |
} | |
return fields | |
} | |
var validateCertificatePath = (certificates) => { | |
if((new Set(certificates)).size !== certificates.length) | |
throw new Error('Failed to validate certificates path! Dublicate certificates detected!'); | |
for(let i = 0; i < certificates.length; i++) { | |
let subjectPem = certificates[i]; | |
let subjectCert = new jsrsasign.X509(); | |
subjectCert.readCertPEM(subjectPem); | |
let issuerPem = ''; | |
if(i + 1 >= certificates.length) | |
issuerPem = subjectPem; | |
else | |
issuerPem = certificates[i + 1]; | |
let issuerCert = new jsrsasign.X509(); | |
issuerCert.readCertPEM(issuerPem); | |
if(subjectCert.getIssuerString() !== issuerCert.getSubjectString()) | |
throw new Error('Failed to validate certificate path! Issuers dont match!'); | |
let subjectCertStruct = jsrsasign.ASN1HEX.getTLVbyList(subjectCert.hex, 0, [0]); | |
let algorithm = subjectCert.getSignatureAlgorithmField(); | |
let signatureHex = subjectCert.getSignatureValueHex() | |
let Signature = new jsrsasign.crypto.Signature({alg: algorithm}); | |
Signature.init(issuerPem); | |
Signature.updateHex(subjectCertStruct); | |
if(!Signature.verify(signatureHex)) | |
throw new Error('Failed to validate certificate path!') | |
} | |
return true | |
} | |
let verifySafetyNetAttestation = (webAuthnResponse) => { | |
let attestationBuffer = base64url.toBuffer(webAuthnResponse.response.attestationObject); | |
let attestationStruct = cbor.decodeAllSync(attestationBuffer)[0]; | |
let jwsString = attestationStruct.attStmt.response.toString('utf8'); | |
let jwsParts = jwsString.split('.'); | |
let HEADER = JSON.parse(base64url.decode(jwsParts[0])); | |
let PAYLOAD = JSON.parse(base64url.decode(jwsParts[1])); | |
let SIGNATURE = jwsParts[2]; | |
/* ----- Verify payload ----- */ | |
let clientDataHashBuf = hash('sha256', base64url.toBuffer(webAuthnResponse.response.clientDataJSON)); | |
let nonceBase = Buffer.concat([attestationStruct.authData, clientDataHashBuf]); | |
let nonceBuffer = hash('sha256', nonceBase); | |
let expectedNonce = nonceBuffer.toString('base64'); | |
if(PAYLOAD.nonce !== expectedNonce) | |
throw new Error(`PAYLOAD.nonce does not contains expected nonce! Expected ${PAYLOAD.nonce} to equal ${expectedNonce}!`); | |
if(!PAYLOAD.ctsProfileMatch) | |
throw new Error('PAYLOAD.ctsProfileMatch is FALSE!'); | |
/* ----- Verify payload ENDS ----- */ | |
/* ----- Verify header ----- */ | |
let certPath = HEADER.x5c.concat([gsr2]).map((cert) => { | |
let pemcert = ''; | |
for(let i = 0; i < cert.length; i += 64) | |
pemcert += cert.slice(i, i + 64) + '\n'; | |
return '-----BEGIN CERTIFICATE-----\n' + pemcert + '-----END CERTIFICATE-----'; | |
}) | |
if(getCertificateSubject(certPath[0]).CN !== 'attest.android.com') | |
throw new Error('The common name is not set to "attest.android.com"!'); | |
validateCertificatePath(certPath); | |
/* ----- Verify header ENDS ----- */ | |
/* ----- Verify signature ----- */ | |
let signatureBaseBuffer = Buffer.from(jwsParts[0] + '.' + jwsParts[1]); | |
let certificate = certPath[0]; | |
let signatureBuffer = base64url.toBuffer(SIGNATURE); | |
let signatureIsValid = crypto.createVerify('sha256') | |
.update(signatureBaseBuffer) | |
.verify(certificate, signatureBuffer); | |
if(!signatureIsValid) | |
throw new Error('Failed to verify the signature!'); | |
/* ----- Verify signature ENDS ----- */ | |
return true | |
} | |
let safetyNetWebAuthnSample = { | |
"rawId": "AZD7huwZVx7aW1efRa6Uq3JTQNorj3qA9yrLINXEcgvCQYtWiSQa1eOIVrXfCmip6MzP8KaITOvRLjy3TUHO7_c", | |
"id": "AZD7huwZVx7aW1efRa6Uq3JTQNorj3qA9yrLINXEcgvCQYtWiSQa1eOIVrXfCmip6MzP8KaITOvRLjy3TUHO7_c", | |
"response": { | |
"clientDataJSON": "eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoiVGY2NWJTNkQ1dGVtaDJCd3ZwdHFnQlBiMjVpWkRSeGp3QzVhbnM5MUlJSkRyY3JPcG5XVEs0TFZnRmplVVY0R0RNZTQ0dzhTSTVOc1pzc0lYVFV2RGciLCJvcmlnaW4iOiJodHRwczpcL1wvd2ViYXV0aG4ub3JnIiwiYW5kcm9pZFBhY2thZ2VOYW1lIjoiY29tLmFuZHJvaWQuY2hyb21lIn0", | |
"attestationObject": "o2NmbXRxYW5kcm9pZC1zYWZldHluZXRnYXR0U3RtdKJjdmVyaDE0MzY2MDE5aHJlc3BvbnNlWRS9ZXlKaGJHY2lPaUpTVXpJMU5pSXNJbmcxWXlJNld5Sk5TVWxHYTJwRFEwSkljV2RCZDBsQ1FXZEpVVkpZY205T01GcFBaRkpyUWtGQlFVRkJRVkIxYm5wQlRrSm5hM0ZvYTJsSE9YY3dRa0ZSYzBaQlJFSkRUVkZ6ZDBOUldVUldVVkZIUlhkS1ZsVjZSV1ZOUW5kSFFURlZSVU5vVFZaU01qbDJXako0YkVsR1VubGtXRTR3U1VaT2JHTnVXbkJaTWxaNlRWSk5kMFZSV1VSV1VWRkVSWGR3U0ZaR1RXZFJNRVZuVFZVNGVFMUNORmhFVkVVMFRWU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2QTZHeVZfck1VRlhSZzEyVEtSb0ROLXJhSG9NSzY3SGdCbk5Yc0QtOUtjaG1TVFpBWWZfLXFKZE1wN1BhYml4VnF4ZDdDQzFxTFBPaUZYLVd5RGJzZlltNmRabFFiODhSd2R6LVEyUVJfTDFCN3NTaURlV1lTeDZmMm10MlQ0WXQ4MjNGNHNGYk8zVlpXM1RacmRRLXBlMVFWMEZYTTRUQ1dXbWVVRUUyWEJmaFVYbHJ5MEFicWhnQUNsWWFGcG8xdUhXUjhEOFkweDhtUDFocmVTMUtNN2NfT01lc1E5dl9mdlBETUE0SEUtYlpZbHZrRVV2VmFCeFpWVzB2SXN4eWxiWllSNVMxSjIwSXRPLV9kSDFERWRkY1kzcmc3bzd6RlJGSGFnd0QyN3dCMzlCTmk4cVNVcG1heEk1VWhrNE04X3BDSWtmLXBwaUFoYXV0aERhdGFYxZVpCI8ezuMjKVQDXb0Q18rjkTBaJ1G1WbuP18uyKb3URQAAAAAAAAAAAAAAAAAAAAAAAAAAAEEBkPuG7BlXHtpbV59FrpSrclNA2iuPeoD3Kssg1cRyC8JBi1aJJBrV44hWtd8KaKnozM_wpohM69EuPLdNQc7v96UBAgMmIAEhWCBVEWSlJerLbRupcvBaXA5Cqpp1Ba46HZTH-dqgmeMCYSJYIIlzYLPXaVavxbpZ4G6ZJWJ6hwW_NgiKAHpSNL8Bwf_d" | |
} | |
} | |
verifySafetyNetAttestation(safetyNetWebAuthnSample) |
Have error "Failed to validate certificate path! Issuers don't match!" in validateCertificatePath function.
subjectCert.getIssuerString() /C=US/O=Google Trust Services LLC/CN=GTS CA 1D4
issuerCert.getSubjectString() /C=US/O=Google Trust Services LLC/CN=GTS CA 1D4
subjectCert.getIssuerString() /C=US/O=Google Trust Services LLC/CN=GTS Root R1
issuerCert.getSubjectString() /C=US/O=Google Trust Services LLC/CN=GTS Root R1
subjectCert.getIssuerString() /C=BE/O=GlobalSign nv-sa/OU=Root CA/CN=GlobalSign Root CA
issuerCert.getSubjectString() /OU=GlobalSign Root CA - R2/O=GlobalSign/CN=GlobalSign
I don't know what to do...
@VovkViktor , getting same issue, if you found any solution. please reply.
/C=US/O=Google Trust Services LLC/CN=GTS CA 1D4
/C=US/O=Google Trust Services LLC/CN=GTS CA 1D4
/C=US/O=Google Trust Services LLC/CN=GTS Root R1
/C=US/O=Google Trust Services LLC/CN=GTS Root R1
/C=BE/O=GlobalSign nv-sa/OU=Root CA/CN=GlobalSign Root CA
/OU=GlobalSign Root CA - R2/O=GlobalSign/CN=GlobalSign
Error: Failed to validate certificate path! Issuers dont match!
@kranthi2210 Hi man! I found a new "gsr2" certificate that works for me! The current certificate will be expiring soon or already expired
MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAwMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxTaWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZjc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavpxy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdGsnUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N89iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0BAQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOzyj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymPAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUadDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
@VovkViktor Hi , Thanks a lot. you are saving my time. i had one doubt how to get this key, can you please explain.
Thanks. Getting index of() undefined error in jsrsasign.js in both validateCertificatePath method and getCertificateSubject method. Please help me.