When you see "Verify return code: 19 (self signed certificate in certificate chain)
", then, either the servers is really trying to use a self-signed certificate (which a client is never going to be able to verify), or OpenSSL hasn't got access to the necessary root but the server is trying to provide it itself (which it shouldn't do because it's pointless - a client can never trust a server to supply the root corresponding to the server's own certificate).
Again, adding -showcerts will help you diagnose which.