Add peer name auth (i.e. server auth) support to AsyncSSLSocket through SSLContext
Summary: This change adds basic support for server auth through AsyncSSLSocket and fills in the implementation under SSLContext::authenticate() to support peer name verification. virtual void SSLContext::authenticate( bool checkPeerCert, bool checkPeerName, const std::string& peerName = std::string()); SSLContext::authenticate signature has parameters intended for server-auth scenarios, but it doesn't have an implementation underneath it and silently ignores the checkPeerName and peerName parameters. This change implements the intended behavior through OPENSS's SSL_set1_host. The intended behavior is as follows: * When checkPeerName is false, the behavior is unchanged and this should cover all existing use cases. * When checkPeerName is true, either the peerName or the servername (suppled through the AsyncSSLSocket constructor) in this given order is expected to be present in the SAN or CN of the peer's certificate as described in [the OPENSSL documentation](https://www.openssl.org/docs/man1.1.0/man3/SSL_add1_host.html). Socket will error our if neither name is supplied. Wildcard matching when checking the name is intentionally disabled for now since there is no known need for it at the moment. Unit tests are added to cover both positive and negative scenarios around SSL server name auth. Reviewed By: mingtaoy Differential Revision: D18162775 fbshipit-source-id: d275f5e2e9e760895c27ba9d73cf8b6a2d0ff599
Showing
Please register or sign in to comment