Ssl – How to setup a TLS/SSL connection using openssl

authenticationopensslssl

Let's say I have PC A and PC B.
Assuming both have certificates signed by a CA.
How can I do mutual authentication here using openssl. What are the commands I have to use ? Brief explanation with some commands will help a lot.

Best Answer

Well, to simply connect to PC using openssl you have to use openssl s_server on one side and openssl s_client on another side:

PCA> openssl s_server -cert ./server.crt -key ./server.key -accept 8443
PCB> openssl s_client -connect PCA:8443

And if you really want mutual authentication here using openssl, you should add verification checks for openssl:

PCA> openssl s_server -cert ./server.crt -key ./server.key -accept 8443 -Verify on -verify_return_error
PCB> openssl s_client -connect PCA:8443 -cert ./client.crt -key ./client.key -verify on -verify_return_error 

so both sides will drop connection in case of there are problems with certificates.