Thanks @Ramachandra_Tummala for quick response. I really appreciate it.
Is localhost your hostname?
Yes.
The host parameter should match with CN from your certificate i,e when you present certificate it will verify against the server
CN and host parameter is same.
I think the certificate needs to be generated different way if you want to connect with localhost
What is that? Let me know if you have any idea.