Summary: Server can find out client's common name through
Cpp2ConnContext::getPeerCommonName
Reviewed By: @siyengar
Differential Revision:
D2469588
class AsyncSSLSocket : public virtual AsyncSocket {
public:
typedef std::unique_ptr<AsyncSSLSocket, Destructor> UniquePtr;
+ using X509_deleter = folly::static_function_deleter<X509, &X509_free>;
class HandshakeCB {
public:
void setReadCB(ReadCallback* callback) override;
+ /**
+ * Returns the peer certificate, or nullptr if no peer certificate received.
+ */
+ std::unique_ptr<X509, X509_deleter> getPeerCert() const {
+ if (!ssl_) {
+ return nullptr;
+ }
+
+ X509* cert = SSL_get_peer_certificate(ssl_);
+ return std::unique_ptr<X509, X509_deleter>(cert);
+ }
+
private:
void init();