SSL Certificates are verified by the client.
The server typically will verify the certificate is not broken or corrupt on start-up, but most servers don't actually validate the legitimacy of their certificate.
Why verify the certificate?
Verification of the server certificate is important because otherwise the client can't really know who it is communicating with. MITM (Man In the Middle) attacks can take place where a third party is intercepting both sides of the communication and they can provide their data to you instead of the data from the server which you thought you were receiving.
A little bit about certificate types
Most certificates are signed by CAs, there are also self-signed certificates, and pinned certificates. I advise using a certificate signed by a CA whenever possible. The Second best option (which generally can only be used within an organization) would using your own internal CA and then self-signing your server cert with your CA cert, this is known as a self-signed certificate and it won't be trusted automatically by any clients or browsers which receive it.
In the self-signed option you must import your CA public key into your CA key store for your server certificate to be trusted. Finally there is simply a pinned certificate, this is where you simply tell your browser to trust an otherwise untrusted certificate (do not do this).
Warning - You should avoid pinning certificates because they are almost impossible to replace during a compromise, and certificates should be schedule to expire within a reasonable period, and be regularly rotated. Pinning makes that very difficult if almost impossible in some situations.
Types of certificates
- CA Signed (Needed to operate a secure site on the WWW)
- Self Signed (Good for internal organization usage, internal company wikis for example)
- Pinned (Avoid)
What kind of verification happens?
So you have a certificate, first you configure your server to use that certificate.
Now when a client comes along and requests a secure connection to your site (as indicated by connecting to port 443 in in the case of HTTPS). Your server sends it's public (not private) certificate and begins a secure handshake. One such handshake is called a Diffie–Hellman key exchange. The handshake itself is beyond the scope of this question.
Before participating in the key exchange, the browser will first examine the certificate which the server provided. For it to be valid several checks must be successful.
There are some of the checks performed.
Does this certificate contain the hostname which matches the hostname we connected to?
- If NO, does the certificate include a wildcard CN (Common Name)?
- If YES, does that CN have a valid "wildcard" that matches the host name we're connected to? YES/NO
Does the certificate include a CRL (Certificate Revocation List)? If so, does that CRL indicate that this certificate is still valid? YES/NO
Is this certificate signed by a known certificate authority (CA)? YES/NO
- Only if NO, does this client (browser) have a public certificate (which matches the certificate offered by this server), which has been marked as Trusted? YES/NO *This is also known as a pinned certificate, as you are not relying on a CA to verify it's authenticity.
For the browser to trust the certificate, and by proxy the server. Then we must check each of the Yes boxes above
Other security stuff that makes the world safer
Now there are other things not "specific" to the certificate which are also verified.
For example, both the client and server must agree on the handshake method, the ciphers used, the hashing algorithm used, and other things.
The server may also pass special HTTPS security flags instructing the browser not to trust other certificates for this service for a period of time (this is known as certificate pinning). Certificate pinning like that used in "Strict Transport Security" (not to be confused with pinning a certificate as mentioned above) can help prevent MITM (man in the middle) attacks. This is one of the many extra security features that HTTPS Strict Transport Security offers.
Once all of the security checks have been certified the browser sends any request it had to the server and the server responds appropriately.