const AsyncTransportCertificate* AsyncSSLSocket::getPeerCertificate() const {
  if (peerCertData_) {
    return peerCertData_.get();
  }
  if (ssl_ != nullptr) {
    auto peerX509 = SSL_get_peer_certificate(ssl_.get());
    if (peerX509) {
      // already up ref'd
      folly::ssl::X509UniquePtr peer(peerX509);
      auto cn = OpenSSLUtils::getCommonName(peerX509);
      peerCertData_ = std::make_unique<BasicTransportCertificate>(
          std::move(cn), std::move(peer));
    }
  }
  return peerCertData_.get();
}
const AsyncTransportCertificate* AsyncSSLSocket::getPeerCertificate() const {
  if (peerCertData_) {
    return peerCertData_.get();
  }
  if (ssl_ != nullptr) {
    auto peerX509 = SSL_get_peer_certificate(ssl_.get());
    if (peerX509) {
       
      folly::ssl::X509UniquePtr peer(peerX509);
      auto cn = OpenSSLUtils::getCommonName(peerX509);
      peerCertData_ = std::make_unique<BasicTransportCertificate>(
          std::move(cn), std::move(peer));
    }
  }
  return peerCertData_.get();
}