title: How to get the remote/peer IP address from an SSL/ssl_st structure in C?
body: <p>The things I have previously tried are getting the socket fd from <code>SSL_get_wfd</code> and then passing it to <code>getpeername</code>. I also looked the the BIO object/functions but without any luck. Attempted to look at the openSSL implementation in <code>/usr/include/openssl</code> but then again with no luck.</p>
  
  <p>Does anyone know how to get the remote IP address (and port) to which an openSSL socket is connected?</p>
  
  <p>Some context:</p>
  
  <pre><code>socket fd: 64 // the file descriptor doesn't look incorrect (to me)
  after getaddress, socklen: 28 // the length of the plausible address also looks correct
  sockaddr ptr: 0x7b0b0fcac0, val: 0x0 // the pointer is empty despite being allocated :(
  </code></pre>
  
  <p>edit: the documentation I based my work on:
  <a href="https://docs.huihoo.com/doxygen/openssl/1.0.1c/structssl__st.html" rel="nofollow noreferrer">https://docs.huihoo.com/doxygen/openssl/1.0.1c/structssl__st.html</a></p>