Understand HTTPS certificate certification at one time


Understand HTTPS certificate certification at one time


TLS (Transport Layer Security) and its predecessor, secure sockets layer, is a security protocol, which aims to provide security and data integrity for Internet communication.

Understand HTTPS certificate certification at one time

As shown in the picture,TLSWhen establishing a connection, you need to

  1. Client sends clienthello (including supported protocol versions, encryption algorithms, andRandom number a (client random))To server
  2. The server returns serverhello, public key, certificateRandom number B (server random)To client
  3. After the client uses the CA certificate to verify that the returned certificate is correct. generateRandom number C (premaster secret), encrypt it with public key and send it to the server
  4. Server sidePrivate keyDeclassifiedRandom number C (premaster secret), and then according to the obtainedGenerating symmetric key by random number ABC (encryption algorithm determined by Hello)And send the data to be sent with symmetric encryption
  5. The client uses the symmetric key (the client also uses the random number ABC to generate the symmetric key) to decrypt the data.
  6. Both sides hold symmetric keyCommunication using symmetric encryption algorithm

And this processServer certificateIt’s crucial.


A certificate used to prove the identity of the owner of a public key

First of all, we need to know how certificates come from.

The digital certificate is generally issued by the digital certificate certification authority, which requires

  • Approved by applicantAsymmetric encryption algorithm (RSA)Generate a pairPublic keyandsecret key, and then send the required application information (country, domain name, etc.) together with the public key toCertification authority (CA)
  • Passed after Ca organization confirms it is correctMessage digest algorithm(MD5, Sha) generate the summary signature m of the whole application information, and thenSignature m and the digest algorithm useduseCA’s own private keyEncrypt

The certificate contains

  • Public key
  • Certificate owner identity
  • Digital certificate authority (issuer) information
  • The digital signature of the document and the algorithm used by the publisher
  • Term of validity

The format and verification method of certificate generally follow the international standard X.509.

Understand HTTPS certificate certification at one time

Certification authority (CA)

Digital certificate authority (CA), also known as e-commerce certification center and e-commerce certification authority, is the authority responsible for issuing and managing digital certificates, and as a trusted third party in e-commerce transactions, it bears the responsibility for the legality inspection of public key in the public key system.

In fact, any individual / organization can become a Ca (self signed certificate), but the certificate client you issue does not trust, and it also needs authority as mentioned above. such asSymantec、Comodo、Godaddy、Digicert

If the client trusts these CAS, it will keep their localRoot certificateroot certificate),Root certificate is CA’s own certificate, is the beginning of the certificate validation chain.
The root certificate does not have an authority (it is already authoritative) to do digital signature for it, so it is self signed certificate.

CA will pass.Intermediate certificateReplace the root certificate with the server-side certificate signature to ensure that the root certificate key is absolutely inaccessible.

Godaddy explained

What is an intermediate certificate?

Certificate trust chain

As mentioned above, it is necessary to apply for certificate from caCA’s private keyThe signature digest of the whole certificate is encrypted asymmetrically, that is, the certificate can be encrypted throughThe public key of CATo decryptSignature summary of certificate.
When we use it againSame digest algorithm(there is an algorithm used to save the certificate) sign the entire certificate. If the signature obtained is consistent with the signature on the certificate, the certificate is trustworthy.

In the same way, intermediary certificates can also be proved to be trustworthy in this way. This whole process is calledTrust chain(Chain of trust)。

That’s meAbsolutelyTrust you (a > b); youAbsolutelyBelieve him (b > C); equal to meAbsolutelyTrust him (a > C)

Here is the whole process:

Understand HTTPS certificate certification at one time

  1. The client gets the certificate returned by the server and gets it through readingIssuer of server certificate
  2. The client goes to the operating system to look up the certificate of this publishing institution. If it is not the root certificate, continue recursionUntil you get the root certificate
  3. useThe public key of the root certificategoDecryption verificationOf the previous certificateLegalityAnd then take the public key of the upper certificate to verify the validity of the higher certificate.
  4. Finally, verify that the server-side certificate isTrustworthy.


Https://www.wikiwand.com/zh/ root certificate
Https://www.wikiwand.com/zh-hans/trust chain
Https://www.wikiwand.com/zh-hans/certification authority


More excellent content, pleaseFocus on WeChat public number [geek favorites]Get, plus group can also communicate and discuss with friends!