I have been looking at the SSL Certificate Trust Model, and there is something that does not make sense. If I am correct, the trust model makes it that if there is a chain of certificates with a trusted root certificate at the top of the chain, all certificates in this chain will be trusted. This does not make sense because then I could create a valid certificate for google.com with my own key pair. I would do this by taking the certificate chain of google.com, lets say Verisign, then google.com. I would leave the root certificate as it is, but modify the key pair in the google.com certificate. This certificate chain would be trusted because the root certificate is trusted, therefore all other certificates are trusted. This would allow you to create a man in the middle attack.
SSL certificates have an extension field that defines what a certificate is allowed to be used for.
When you buy a certificate from VeriSign with your certificate signing request, it typically will not include the extension permission for signing downstream certificates with your certificate; especially for any domain you don't have authority for.
Take google.com for instance (root to leaf node):
- Equifax Secure CA - Root CA (hence implicit downstream signing authority)
- GeoTrust Global CA - Has Certificate Signer property
- Google Internet Authority G2 - Has Certificate Signer property but can only sign leaf nodes
- *.google.com - Wildcard domain certificate with no authority to sign other certificates.
The browser checks validity from the root to the leaf. Any authority claimed by a leaf or intermediate certificate is assumed to have been authorised by the certificate that signed it; eventually culminating in the trust given to and from the Root Certification Authority.
You are missing a very important part of a Digital Certificate here. That part is Digital Signature. Basically, a Digital Certificate consists of 3 parts:
- A public key.
- Certificate information. ("Identity" information about user, such as name, user ID, and so on.)
- One or more digital signatures.
A digital signature is an encrypted hash of the certificate. It is basically a digest (e.g. SHA-1) of the certificate itself, singed (verified) by the private key of the CA. This is what tells your browser that this certificate is verified by someone (someone your browser can also trust).
As you said, you can easily take a certificate and change it. But what you really can't change here is this digital signature (since you don't have the private key belonging to that trusted someone). Hence, your browser will immediately detect it because it will not be able to verify the digital signature.