-
Notifications
You must be signed in to change notification settings - Fork 181
Adds most logic needed for validating cert chain #101
base: master
Are you sure you want to change the base?
Conversation
} catch (CertificateEncodingException e) { | ||
throw new RuntimeException(); | ||
} | ||
this.attestationCert = X509Util.encodeCertArray(tokenData.getAttestationCertificateChain()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this is no longer just a cert. Could you use a longer name, e.g. attestationCertChain? attestationCertOrCertAndChain? Ick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Notes: * This is completely backward compatible to what U2F does now. * The registration request can now have more than one X.509 certificate. The chain must be DER encoded (basically, the X.509 certs are DER encoded and then concatenated one after anoter. * As noted in many comments, the leaf is in the 0th element of the chain, followed by intermediary certs. * The current code does not yet ship with the final Android attestation root CA, so all Android attestations will have "chain validated: false"
Ping |
import com.google.u2f.U2FException; | ||
import com.google.u2f.key.messages.AuthenticateRequest; | ||
import com.google.u2f.key.messages.AuthenticateResponse; | ||
import com.google.u2f.key.messages.RegisterRequest; | ||
import com.google.u2f.key.messages.RegisterResponse; | ||
import com.google.u2f.tools.X509Util; | ||
|
||
import org.bouncycastle.util.Arrays; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't java.util.Arrays.copyOfRange sufficient? It's in jre7, at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, removed.
} | ||
|
||
// Now attempt to verify up to one of the roots | ||
boolean validated = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This default value, combined with the for loop that will not execute for an empty caCerts list, will allow the caller to get validated = true when the caCerts list is empty. Perhaps that's what you mean, but it certainly looks odd.
8590f57
to
14205c3
Compare
Notes:
certificate. The chain must be DER encoded (basically, the X.509
certs are DER encoded and then concatenated one after anoter.
chain, followed by intermediary certs.
root CA, so all Android attestations will have "chain validated:
false"