The certificate files we obtain all contain the public key of the other party. After verifying the validity of the certificate, we can extract the public key of the certificate for subsequent secure communication.
The client extracts the public key of the server certificate:
openssl x509 -in client.crt -pubkey -noout > client.key
operation result:
The server extracts the public key of the client certificate:
openssl x509 -in server.crt -pubkey -noout > server.key
operation result:
Reference: openssl extracts public key from certificate