on my FreeBSD vm, with Joomla, I was getting the error
fsockopen(): unable to connect to ssl://localhost:443 (Unknown error)
when using a contact form and also the module updating process.
After reading other notes on here, regarding certificate validation, I installed the port ca_root_nss
(Root certificates from certificate authorities included in the Mozilla
NSS library and thus in Firefox and Thunderbird.)
Now it works