How do certificates work with digital signatures and encryption?

In the previous section, we looked at a scenario where Simran was sending encrypted and digitally signed data to Brian. During the process, we saw how Simran and Brian used each other's private and public keys. A public key has to be shared between two parties. Now, the problem we have is to work out how exactly the system knows that Brian's public key is his, and not from someone that is pretending to be Brian? In order to overcome this challenge, we can use certificates to verify whether shared public keys are from their purported source. Let's introduce certificates to the previous example and see how things would work.

The digital signature process works as follows:

The data encryption process works as follows:

During the certificate validation process, the system will verify the certificates using the CA's public key as it will confirm the authenticity of the CA. It also checks the validity period of the certificates using the Valid to value in the certificate.

The data decryption process works as follows:

The signature verification process works as follows:

The rest of the steps are exactly the same as I explained in the Signing, encryption, and decryption section.